mirror of
https://github.com/Royce551/FRESHMusicPlayer-WinForms.git
synced 2025-01-22 10:51:58 -05:00
Fix normal sorting not working
This commit is contained in:
parent
2cdd0aabb2
commit
e7153cf19d
1 changed files with 24 additions and 15 deletions
|
@ -416,22 +416,31 @@ namespace FRESHMusicPlayer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SortLibraryButton_Click(object sender, EventArgs e)
|
private async void SortLibraryButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
List<string> songs = DatabaseHandler.ReadSongs();
|
if (!TaskIsRunning) await Task.Run(() =>
|
||||||
List<(string song, string path)> sort = new List<(string song, string path)>();
|
{
|
||||||
|
TaskIsRunning = true;
|
||||||
|
List<string> songs = DatabaseHandler.ReadSongs();
|
||||||
|
List<(string song, string path)> sort = new List<(string song, string path)>();
|
||||||
|
|
||||||
foreach (string x in songs)
|
foreach (string x in songs)
|
||||||
{
|
{
|
||||||
ATL.Track track = new ATL.Track(x);
|
Track track = new Track(x);
|
||||||
sort.Add(($"{track.Artist} - {track.Title}", x));
|
sort.Add(($"{track.Artist} - {track.Title}", x));
|
||||||
}
|
}
|
||||||
sort.Sort();
|
sort.Sort();
|
||||||
DatabaseHandler.ClearLibrary();
|
DatabaseHandler.ClearLibrary();
|
||||||
foreach ((string song, string path) x in sort)
|
foreach ((string song, string path) x in sort)
|
||||||
{
|
{
|
||||||
DatabaseHandler.ImportSong(x.path);
|
DatabaseHandler.ImportSong(x.path);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
TaskIsRunning = false;
|
||||||
|
LibraryNeedsUpdating = true;
|
||||||
|
Notification notification = new Notification("Success!", "Your database was sorted successfully.", 5000);
|
||||||
|
notification.Location = Location;
|
||||||
|
notification.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ReverseLibraryButton_Click(object sender, EventArgs e)
|
private async void ReverseLibraryButton_Click(object sender, EventArgs e)
|
||||||
|
@ -444,7 +453,7 @@ namespace FRESHMusicPlayer
|
||||||
|
|
||||||
foreach (string x in songs)
|
foreach (string x in songs)
|
||||||
{
|
{
|
||||||
ATL.Track track = new ATL.Track(x);
|
Track track = new Track(x);
|
||||||
sort.Add(($"{track.Artist} - {track.Title}", x));
|
sort.Add(($"{track.Artist} - {track.Title}", x));
|
||||||
}
|
}
|
||||||
sort.Sort();
|
sort.Sort();
|
||||||
|
|
Loading…
Reference in a new issue