Fixed PlaylistDetailViewModels's "Playlist" object not properly synchronizing (events, locking) to the playlist manager's current playlist at constructor time.

This commit is contained in:
2026-08-09 11:28:45 -04:00
parent afcae0761b
commit 2be865d445
5 changed files with 29 additions and 16 deletions

View File

@@ -47,7 +47,16 @@ public partial class PlaylistDetailViewModel : ViewModelBase
public Playlist? Playlist
{
get => _playlist;
private set => SetProperty(ref _playlist, value);
private set
{
_playlist?.PlaylistUpdated -= OnPlaylistUpdated;
_playlist = _playlistManager.CurrentPlaylist;
_playlist?.PlaylistUpdated += OnPlaylistUpdated;
IsPlaylistLocked = Playlist?.IsLocked ?? false;
SetProperty(ref _playlist, value);
}
}
private PlaylistSong? _playingSong;
@@ -273,14 +282,9 @@ public partial class PlaylistDetailViewModel : ViewModelBase
Playlist.MoveSong(oldIndex, newIndex);
}
private void OnPlaylistChanged(object? sender, EventArgs e)
private void OnPlaylistChanged(object? sender, PlaylistChangedEventArgs e)
{
Playlist?.PlaylistUpdated -= OnPlaylistUpdated;
Playlist = _playlistManager.CurrentPlaylist;
Playlist?.PlaylistUpdated += OnPlaylistUpdated;
IsPlaylistLocked = Playlist?.IsLocked ?? false;
Playlist = e.NewPlaylist;
UpdateFilteredSongs();
}