From 5142477b5eeff5b2d28624101c65f2742971f3c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Marchal?= Date: Tue, 19 Apr 2022 01:17:48 +0200 Subject: [PATCH] GetPlaylist more cleverly --- Views/MainWindow.xaml.cs | 15 +++------------ Views/Shuffle.xaml.cs | 7 ++++++- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Views/MainWindow.xaml.cs b/Views/MainWindow.xaml.cs index 7f57a70..80833e6 100644 --- a/Views/MainWindow.xaml.cs +++ b/Views/MainWindow.xaml.cs @@ -54,9 +54,6 @@ namespace unison _mpd.QueryStats(); _settingsWin.UpdateStats(); - // _mpd.QueryPlaylist().ConfigureAwait(false); - // to remove - ConnectionOkIcon.Visibility = Visibility.Visible; ConnectionFailIcon.Visibility = Visibility.Collapsed; @@ -132,18 +129,12 @@ namespace unison if (!_shuffleWin.GetContinuous()) return; - await Task.Run(async () => - { - Debug.WriteLine("start continuous"); + Debug.WriteLine("playlist length => " + _mpd.GetStatus().PlaylistLength); - await _mpd.QueryPlaylist(); - - Debug.WriteLine("queried playlist"); - }); - - if (_mpd.GetPlaylistCount() > 5) + if (_mpd.GetStatus().PlaylistLength > 4) return; + Debug.WriteLine("start continuous handling"); _mpd.CanPrevNext = false; await _shuffleWin.HandleContinuous(); _mpd.CanPrevNext = true; diff --git a/Views/Shuffle.xaml.cs b/Views/Shuffle.xaml.cs index e9d9a90..a2decad 100644 --- a/Views/Shuffle.xaml.cs +++ b/Views/Shuffle.xaml.cs @@ -342,9 +342,14 @@ namespace unison public async Task HandleContinuous() { if (!_continuous) + { + Debug.WriteLine("continuous return nothing!"); return; + } + Debug.WriteLine("continuous __before__ add to queue"); await AddToQueue(5); + Debug.WriteLine("continuous __after__ add to queue"); } private async void ContinuousShuffle_Checked(object sender, RoutedEventArgs e) @@ -354,7 +359,7 @@ namespace unison else _continuous = false; - if (_mpd.GetPlaylistCount() < 5) + if (_mpd.GetStatus().PlaylistLength < 5) await HandleContinuous(); } }