Use callback to check whether downloading manifest successfully.

This commit is contained in:
弘韬 张 2021-01-20 18:00:16 +08:00
parent 2463582af0
commit 912cca6c5f

View file

@ -30,7 +30,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
return new PluginsManagerSettings(viewModel);
}
public async Task InitAsync(PluginInitContext context)
public Task InitAsync(PluginInitContext context)
{
Context = context;
viewModel = new SettingsViewModel(context);
@ -38,16 +38,19 @@ namespace Flow.Launcher.Plugin.PluginsManager
contextMenu = new ContextMenu(Context);
pluginManager = new PluginsManager(Context, Settings);
var updateManifestTask = pluginManager.UpdateManifest();
if (await Task.WhenAny(updateManifestTask, Task.Delay(1000)) == updateManifestTask)
_ = updateManifestTask.ContinueWith(t =>
{
lastUpdateTime = DateTime.Now;
}
else
{
context.API.ShowMsg("Plugin Manifest Download Fail.",
"Please check if you can connect to github.com. "+
if (t.IsCompletedSuccessfully)
lastUpdateTime = DateTime.Now;
else
{
context.API.ShowMsg("Plugin Manifest Download Fail.",
"Please check if you can connect to github.com. " +
"This error means you may not be able to Install and Update Plugin.", pluginManager.icoPath, false);
}
}
});
return Task.CompletedTask;
}
public List<Result> LoadContextMenus(Result selectedResult)