Make InstallOrUpdate to async

This commit is contained in:
弘韬 张 2020-12-29 18:33:53 +08:00
parent efa4908f37
commit d4f94c66ac
3 changed files with 8 additions and 9 deletions

View file

@ -8,7 +8,6 @@ using System.Threading.Tasks;
using System.Windows;
using JetBrains.Annotations;
using Squirrel;
using Newtonsoft.Json;
using Flow.Launcher.Core.Resource;
using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.Infrastructure;
@ -17,6 +16,7 @@ using Flow.Launcher.Infrastructure.Logger;
using System.IO;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using System.Text.Json.Serialization;
namespace Flow.Launcher.Core
{
@ -117,13 +117,13 @@ namespace Flow.Launcher.Core
[UsedImplicitly]
private class GithubRelease
{
[JsonProperty("prerelease")]
[JsonPropertyName("prerelease")]
public bool Prerelease { get; [UsedImplicitly] set; }
[JsonProperty("published_at")]
[JsonPropertyName("published_at")]
public DateTime PublishedAt { get; [UsedImplicitly] set; }
[JsonProperty("html_url")]
[JsonPropertyName("html_url")]
public string HtmlUrl { get; [UsedImplicitly] set; }
}

View file

@ -22,7 +22,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
internal PluginsManager pluginManager;
private DateTime lastUpdateTime;
private DateTime lastUpdateTime = DateTime.MinValue;
public Control CreateSettingPanel()
{

View file

@ -87,7 +87,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
};
}
internal void InstallOrUpdate(UserPlugin plugin)
internal async Task InstallOrUpdate(UserPlugin plugin)
{
if (PluginExists(plugin.ID))
{
@ -127,7 +127,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"),
Context.API.GetTranslation("plugin_pluginsmanager_please_wait"));
Http.Download(plugin.UrlDownload, filePath);
await Http.Download(plugin.UrlDownload, filePath).ConfigureAwait(false);
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"),
Context.API.GetTranslation("plugin_pluginsmanager_download_success"));
@ -264,8 +264,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
Action = e =>
{
Application.Current.MainWindow.Hide();
InstallOrUpdate(x);
_ = InstallOrUpdate(x); // No need to wait
return ShouldHideWindow;
},
ContextData = x