Added in more locking/unlocking logic.

This commit is contained in:
2026-08-03 22:57:40 -04:00
parent 2b78ac5667
commit de16ac6240
4 changed files with 77 additions and 16 deletions

View File

@@ -132,6 +132,13 @@ public partial class PlaylistDetailViewModel : ViewModelBase
}
];
private bool _isPlaylistLocked;
public bool IsPlaylistLocked
{
get => _isPlaylistLocked;
private set => SetProperty(ref _isPlaylistLocked, value);
}
public IAsyncRelayCommand PlaySongCommand { get; }
public IAsyncRelayCommand NewPlaylistCommand { get; }
public IAsyncRelayCommand AddFilesCommand { get; }
@@ -151,7 +158,8 @@ public partial class PlaylistDetailViewModel : ViewModelBase
public IRelayCommand RandomizeSelectedCommand { get; }
public IRelayCommand ReverseAllCommand { get; }
public IRelayCommand ReverseSelectedCommand { get; }
public IRelayCommand ToggleLockCommand { get; }
public IRelayCommand LockPlaylistCommand { get; }
public IRelayCommand UnlockPlaylistCommand { get; }
public bool IsUserUpdating { get; set; }
private bool _isUserInitiatingSongChange;
@@ -204,7 +212,8 @@ public partial class PlaylistDetailViewModel : ViewModelBase
RandomizeSelectedCommand = new RelayCommand(RandomizeSelectedSongs, AreMultipleSongsSelected);
ReverseAllCommand = new RelayCommand(ReverseAllSongs);
ReverseSelectedCommand = new RelayCommand(ReverseSelectedSongs, AreMultipleSongsSelected);
ToggleLockCommand = new RelayCommand(ToggleLock);
LockPlaylistCommand = new RelayCommand(LockPlaylist);
UnlockPlaylistCommand = new RelayCommand(UnlockPlaylist);
FilteredPlaylistSongs.CollectionChanged += OnFilteredPlaylistSongsCollectionChanged;
@@ -267,6 +276,8 @@ public partial class PlaylistDetailViewModel : ViewModelBase
Playlist = _playlistManager.CurrentPlaylist;
Playlist?.PlaylistUpdated += OnPlaylistUpdated;
IsPlaylistLocked = Playlist?.IsLocked ?? false;
UpdateFilteredSongs();
}
@@ -286,6 +297,10 @@ public partial class PlaylistDetailViewModel : ViewModelBase
case PlaylistUpdateAction.Reset:
_dispatcherQueue.TryEnqueue(() => ApplyReorderedSongs(e.Songs));
break;
case PlaylistUpdateAction.Lock:
case PlaylistUpdateAction.Unlock:
IsPlaylistLocked = Playlist?.IsLocked ?? false;
break;
}
}
@@ -737,19 +752,14 @@ public partial class PlaylistDetailViewModel : ViewModelBase
RestoreSelectedSongs(selectedPlaylistSongIds);
}
private void ToggleLock()
private void LockPlaylist()
{
if (Playlist == null)
return;
Playlist?.Lock();
}
if (Playlist.IsLocked)
{
Playlist.Unlock();
}
else
{
Playlist.Lock();
}
private void UnlockPlaylist()
{
Playlist?.Unlock();
}
#endregion