|
@@ -4,7 +4,7 @@ namespace FNZCM.BlazorWasm.Helpers
|
|
|
{
|
|
|
public class PlaylistHelper
|
|
|
{
|
|
|
- public event Action Changed ;
|
|
|
+ public event Action Changed;
|
|
|
|
|
|
private readonly LocalStorageHelper localStorage;
|
|
|
|
|
@@ -51,7 +51,7 @@ namespace FNZCM.BlazorWasm.Helpers
|
|
|
Changed?.Invoke();
|
|
|
}
|
|
|
|
|
|
- public void UpdatePlaylistName(Guid playlistId,string name)
|
|
|
+ public void UpdatePlaylistName(Guid playlistId, string name)
|
|
|
{
|
|
|
var pls = PlayListLoadSave;
|
|
|
pls[playlistId] = name;
|
|
@@ -61,5 +61,71 @@ namespace FNZCM.BlazorWasm.Helpers
|
|
|
|
|
|
//TODO: Move order track in playlist
|
|
|
|
|
|
+ public void ListMoveUp(int index)
|
|
|
+ {
|
|
|
+ if (index < 1) return;
|
|
|
+
|
|
|
+ // let's say index = 3
|
|
|
+
|
|
|
+ var pls = PlayListLoadSave;
|
|
|
+
|
|
|
+ var re = new Dictionary<Guid, string>();
|
|
|
+
|
|
|
+ foreach (var item in pls.Take(index - 1)) // take2 0 1
|
|
|
+ {
|
|
|
+ re.Add(item.Key, item.Value);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var item in pls.Skip(index).Take(1)) // skip3t1 3→2
|
|
|
+ {
|
|
|
+ re.Add(item.Key, item.Value);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var item in pls.Skip(index - 1).Take(1)) // skip2t1 2→3
|
|
|
+ {
|
|
|
+ re.Add(item.Key, item.Value);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var item in pls.Skip(index + 1)) // skip4 4 5
|
|
|
+ {
|
|
|
+ re.Add(item.Key, item.Value);
|
|
|
+ }
|
|
|
+
|
|
|
+ PlayListLoadSave = re;
|
|
|
+ Changed?.Invoke();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void ListMoveDown(int index)
|
|
|
+ {
|
|
|
+ var pls = PlayListLoadSave;
|
|
|
+ if (index >= pls.Count - 1) return;
|
|
|
+
|
|
|
+ // let's say index = 3 and count = 6
|
|
|
+
|
|
|
+ var re = new Dictionary<Guid, string>();
|
|
|
+
|
|
|
+ foreach (var item in pls.Take(index)) // take3 012→012
|
|
|
+ {
|
|
|
+ re.Add(item.Key, item.Value);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var item in pls.Skip(index+1).Take(1)) // skip4t1 4→3
|
|
|
+ {
|
|
|
+ re.Add(item.Key, item.Value);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var item in pls.Skip(index).Take(1)) // skip3t1 3→4
|
|
|
+ {
|
|
|
+ re.Add(item.Key, item.Value);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var item in pls.Skip(index + 2)) // skip5 5→5
|
|
|
+ {
|
|
|
+ re.Add(item.Key, item.Value);
|
|
|
+ }
|
|
|
+
|
|
|
+ PlayListLoadSave = re;
|
|
|
+ Changed?.Invoke();
|
|
|
+ }
|
|
|
}
|
|
|
}
|