From 0fabe31fe4344acb49bae294ac4cf23981a1951d Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 6 Jan 2025 21:16:28 +0800 Subject: [PATCH] Improve code quality --- .../PluginsManager.cs | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs index 0ed849bb3..bbb5c179e 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs @@ -163,9 +163,12 @@ namespace Flow.Launcher.Plugin.PluginsManager if (canReportProgress && (prgBox = Context.API.ShowProgressBox(prgBoxTitle, () => { - httpClient.CancelPendingRequests(); - downloadCancelled = true; - prgBox = null; + if (prgBox != null) + { + httpClient.CancelPendingRequests(); + downloadCancelled = true; + prgBox = null; + } })) != null) { await using var contentStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); @@ -185,19 +188,19 @@ namespace Flow.Launcher.Plugin.PluginsManager // check if user cancelled download before reporting progress if (downloadCancelled) return; - - prgBox.ReportProgress(progressValue); + else + prgBox.ReportProgress(progressValue); } // check if user cancelled download before closing progress box if (downloadCancelled) return; - - Application.Current.Dispatcher.Invoke(() => - { - prgBox.Close(); - prgBox = null; - }); + else + Application.Current.Dispatcher.Invoke(() => + { + prgBox.Close(); + prgBox = null; + }); } else { @@ -212,8 +215,8 @@ namespace Flow.Launcher.Plugin.PluginsManager // check if user cancelled download before installing plugin if (downloadCancelled) return; - - Install(plugin, filePath); + else + Install(plugin, filePath); } catch (HttpRequestException e) {