Fixed playlist song pasting logic, so that songs can be pasted into an empty playlist (or a playlist with no selected songs).
This commit is contained in:
@@ -595,7 +595,7 @@ public partial class PlaylistDetailViewModel : ViewModelBase
|
||||
|
||||
private bool CanPasteSongs()
|
||||
{
|
||||
if (Playlist == null || SelectedPlaylistSongs.Count == 0)
|
||||
if (Playlist == null)
|
||||
return false;
|
||||
|
||||
DataPackageView dataPackageView = Clipboard.GetContent();
|
||||
@@ -611,17 +611,21 @@ public partial class PlaylistDetailViewModel : ViewModelBase
|
||||
|
||||
private async Task PasteSongsAsync()
|
||||
{
|
||||
if (Playlist == null || SelectedPlaylistSongs.Count == 0)
|
||||
return;
|
||||
|
||||
int selectedPlaylistSongIndex = Playlist.IndexOf(SelectedPlaylistSongs[0]);
|
||||
|
||||
if (selectedPlaylistSongIndex == -1)
|
||||
if (Playlist == null)
|
||||
return;
|
||||
|
||||
Song[] songs = await GetSongsFromClipboardAsync();
|
||||
int insertIndex = Playlist.Songs.Count;
|
||||
|
||||
Playlist.AddSongs(songs, selectedPlaylistSongIndex + 1);
|
||||
if (SelectedPlaylistSongs.Count > 0)
|
||||
{
|
||||
int selectedPlaylistSongIndex = Playlist.IndexOf(SelectedPlaylistSongs[0]);
|
||||
|
||||
if (selectedPlaylistSongIndex >= 0)
|
||||
insertIndex = selectedPlaylistSongIndex + 1;
|
||||
}
|
||||
|
||||
Playlist.AddSongs(songs, insertIndex);
|
||||
}
|
||||
|
||||
private static async Task<Song[]> GetSongsFromClipboardAsync()
|
||||
|
||||
Reference in New Issue
Block a user