Skip to content

Commit 0fabe31

Browse files
committed
Improve code quality
1 parent 675ee9e commit 0fabe31

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,12 @@ internal async Task InstallOrUpdateAsync(UserPlugin plugin)
163163
if (canReportProgress &&
164164
(prgBox = Context.API.ShowProgressBox(prgBoxTitle, () =>
165165
{
166-
httpClient.CancelPendingRequests();
167-
downloadCancelled = true;
168-
prgBox = null;
166+
if (prgBox != null)
167+
{
168+
httpClient.CancelPendingRequests();
169+
downloadCancelled = true;
170+
prgBox = null;
171+
}
169172
})) != null)
170173
{
171174
await using var contentStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
@@ -185,19 +188,19 @@ internal async Task InstallOrUpdateAsync(UserPlugin plugin)
185188
// check if user cancelled download before reporting progress
186189
if (downloadCancelled)
187190
return;
188-
189-
prgBox.ReportProgress(progressValue);
191+
else
192+
prgBox.ReportProgress(progressValue);
190193
}
191194

192195
// check if user cancelled download before closing progress box
193196
if (downloadCancelled)
194197
return;
195-
196-
Application.Current.Dispatcher.Invoke(() =>
197-
{
198-
prgBox.Close();
199-
prgBox = null;
200-
});
198+
else
199+
Application.Current.Dispatcher.Invoke(() =>
200+
{
201+
prgBox.Close();
202+
prgBox = null;
203+
});
201204
}
202205
else
203206
{
@@ -212,8 +215,8 @@ internal async Task InstallOrUpdateAsync(UserPlugin plugin)
212215
// check if user cancelled download before installing plugin
213216
if (downloadCancelled)
214217
return;
215-
216-
Install(plugin, filePath);
218+
else
219+
Install(plugin, filePath);
217220
}
218221
catch (HttpRequestException e)
219222
{

0 commit comments

Comments
 (0)