diff --git a/DownloadTask.cs b/DownloadTask.cs index 696f34c..0902d3f 100644 --- a/DownloadTask.cs +++ b/DownloadTask.cs @@ -157,7 +157,7 @@ await this.Plugin.Framework.RunOnFrameworkThread(() => { // probably antivirus (ioexception is being used by other process or // access denied) if (ex.IsAntiVirus()) { - await this.Plugin.PluginUi.AddIfNotPresentAsync(new AntiVirusWindow(this.Plugin)); + this.Plugin.PluginUi.OpenAntiVirusWarning(); } else { ErrorHelper.Handle(ex, $"Error downloading version {this.Version}"); } diff --git a/Plugin.cs b/Plugin.cs index 40651ce..7785e07 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -69,7 +69,7 @@ public Plugin() { var showWarning = await DependencyHelper.CheckDependencies(this); if (showWarning) { this.IntegrityFailed = true; - this.PluginUi?.AddIfNotPresent(new AntiVirusWindow(this)); + this.PluginUi?.OpenAntiVirusWarning(); } return showWarning; @@ -159,12 +159,8 @@ public Plugin() { this.LinkPayloads = new LinkPayloads(this); this.CommandHandler = new CommandHandler(this); - if (startWithAvWarning) { - this.PluginUi.AddIfNotPresent(new AntiVirusWindow(this)); - } - - if (checkTask is { Status: TaskStatus.RanToCompletion, Result: true }) { - this.PluginUi.AddIfNotPresent(new AntiVirusWindow(this)); + if (startWithAvWarning || checkTask is { Status: TaskStatus.RanToCompletion, Result: true }) { + this.PluginUi.OpenAntiVirusWarning(); } Task.Run(async () => await this.State.UpdatePackages()); diff --git a/Ui/PluginUi.cs b/Ui/PluginUi.cs index c396b53..e4d4c6e 100644 --- a/Ui/PluginUi.cs +++ b/Ui/PluginUi.cs @@ -65,6 +65,10 @@ private void OpenConfig() { this.Visible = true; } + internal void OpenAntiVirusWarning() { + Task.Run(async () => await this.AddIfNotPresentAsync(new AntiVirusWindow(this.Plugin))); + } + internal bool ShouldForceOpen(Tab tab) { var should = this.ForceOpen == tab; if (should) {