another check to avoid re-update lastUpdateTime

This commit is contained in:
Kevin Zhang 2021-07-04 18:53:40 +08:00
parent 2405af88a6
commit 47cb7a4ebc

View file

@ -38,7 +38,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
viewModel = new SettingsViewModel(context, Settings);
contextMenu = new ContextMenu(Context);
pluginManager = new PluginsManager(Context, Settings);
_ = pluginManager.UpdateManifest().ContinueWith(_ =>
_manifestUpdateTask = pluginManager.UpdateManifest().ContinueWith(_ =>
{
lastUpdateTime = DateTime.Now;
}, TaskContinuationOptions.OnlyOnRanToCompletion);
@ -50,6 +50,8 @@ namespace Flow.Launcher.Plugin.PluginsManager
{
return contextMenu.LoadContextMenus(selectedResult);
}
private Task _manifestUpdateTask = Task.CompletedTask;
public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
{
@ -58,9 +60,9 @@ namespace Flow.Launcher.Plugin.PluginsManager
if (string.IsNullOrWhiteSpace(search))
return pluginManager.GetDefaultHotKeys();
if ((DateTime.Now - lastUpdateTime).TotalHours > 12) // 12 hours
if ((DateTime.Now - lastUpdateTime).TotalHours > 12 && _manifestUpdateTask.IsCompleted) // 12 hours
{
_ = pluginManager.UpdateManifest().ContinueWith(t =>
_manifestUpdateTask = pluginManager.UpdateManifest().ContinueWith(t =>
{
lastUpdateTime = DateTime.Now;
}, TaskContinuationOptions.OnlyOnRanToCompletion);