Await Update when manifest is not ready

This commit is contained in:
弘韬 张 2021-01-29 11:37:26 +08:00
parent 5d894ec154
commit 89453f441d
2 changed files with 14 additions and 4 deletions

View file

@ -88,7 +88,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
{
var s when s.StartsWith(Settings.HotKeyInstall) => await pluginManager.RequestInstallOrUpdate(s, token),
var s when s.StartsWith(Settings.HotkeyUninstall) => pluginManager.RequestUninstall(s),
var s when s.StartsWith(Settings.HotkeyUpdate) => pluginManager.RequestUpdate(s),
var s when s.StartsWith(Settings.HotkeyUpdate) => await pluginManager.RequestUpdate(s, token),
_ => pluginManager.GetDefaultHotKeys().Where(hotkey =>
{
hotkey.Score = StringMatcher.FuzzySearch(search, hotkey.Title).Score;

View file

@ -149,8 +149,19 @@ namespace Flow.Launcher.Plugin.PluginsManager
Context.API.RestartApp();
}
internal List<Result> RequestUpdate(string search)
internal async ValueTask<List<Result>> RequestUpdate(string search, CancellationToken token)
{
if (!pluginsManifest.UserPlugins.Any() &&
_downloadManifestTask.Status != TaskStatus.Running)
{
_downloadManifestTask = pluginsManifest.DownloadManifest();
}
await _downloadManifestTask;
token.ThrowIfCancellationRequested();
var autocompletedResults = AutoCompleteReturnAllResults(search,
Settings.HotkeyUpdate,
"Update",
@ -286,8 +297,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
await _downloadManifestTask;
if (token.IsCancellationRequested)
return null;
token.ThrowIfCancellationRequested();
var searchNameWithoutKeyword = searchName.Replace(Settings.HotKeyInstall, string.Empty).Trim();