Database update feature
This commit is contained in:
@ -334,16 +334,21 @@ namespace unison
|
||||
}, token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private bool UpdateStarted = false;
|
||||
|
||||
private async Task HandleIdleResponseAsync(string subsystems)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (subsystems.Contains("player") || subsystems.Contains("mixer") || subsystems.Contains("output") || subsystems.Contains("options"))
|
||||
if (subsystems.Contains("player") || subsystems.Contains("mixer") || subsystems.Contains("output") || subsystems.Contains("options") || subsystems.Contains("update"))
|
||||
{
|
||||
await UpdateStatusAsync();
|
||||
|
||||
if (subsystems.Contains("player"))
|
||||
await UpdateSongAsync();
|
||||
|
||||
if (subsystems.Contains("update"))
|
||||
UpdateDatabaseSync();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -353,6 +358,30 @@ namespace unison
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDatabaseSync()
|
||||
{
|
||||
if (!UpdateStarted)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
MainWindow MainWin = (MainWindow)Application.Current.MainWindow;
|
||||
MainWin.GetSettings().MPDDatabaseUpdate_Start();
|
||||
});
|
||||
|
||||
UpdateStarted = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
MainWindow MainWin = (MainWindow)Application.Current.MainWindow;
|
||||
MainWin.GetSettings().MPDDatabaseUpdate_Stop();
|
||||
MainWin.UpdateStats();
|
||||
});
|
||||
UpdateStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UpdateStatusAsync()
|
||||
{
|
||||
if (_connection == null || _isUpdatingStatus)
|
||||
@ -611,6 +640,8 @@ namespace unison
|
||||
return _Playlist.ToArray().Count();
|
||||
}
|
||||
|
||||
public void UpdateDB() => SendCommand(new UpdateCommand());
|
||||
|
||||
private string FormatTime(TimeSpan time)
|
||||
{
|
||||
string FormattedTime = "";
|
||||
|
Reference in New Issue
Block a user