Skip to content

Commit 07bb16c

Browse files
committed
Improve code quality
1 parent c06ba59 commit 07bb16c

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ internal async Task InstallOrUpdateAsync(UserPlugin plugin)
161161

162162
if (canReportProgress &&
163163
(prgBox = Context.API.ShowProgressBox($"Download {plugin.Name}...", () =>
164-
{
164+
{
165165
httpClient.CancelPendingRequests();
166166
downloadCancelled = true;
167167
prgBox = null;
@@ -209,15 +209,11 @@ internal async Task InstallOrUpdateAsync(UserPlugin plugin)
209209
else
210210
{
211211
filePath = plugin.LocalInstallPath;
212-
Install(plugin, filePath);
213-
}
212+
Install(plugin, filePath);
213+
}
214214
}
215215
catch (HttpRequestException e)
216216
{
217-
Context.API.ShowMsgError(
218-
string.Format(Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"), plugin.Name),
219-
Context.API.GetTranslation("plugin_pluginsmanager_download_error"));
220-
Log.Exception("PluginsManager", "An error occurred while downloading plugin", e);
221217
// force close progress box
222218
Application.Current.Dispatcher.Invoke(() =>
223219
{
@@ -227,14 +223,17 @@ internal async Task InstallOrUpdateAsync(UserPlugin plugin)
227223
prgBox = null;
228224
}
229225
});
226+
227+
// show error message
228+
Context.API.ShowMsgError(
229+
string.Format(Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"), plugin.Name),
230+
Context.API.GetTranslation("plugin_pluginsmanager_download_error"));
231+
Log.Exception("PluginsManager", "An error occurred while downloading plugin", e);
232+
230233
return;
231234
}
232235
catch (Exception e)
233236
{
234-
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"),
235-
string.Format(Context.API.GetTranslation("plugin_pluginsmanager_install_error_subtitle"),
236-
plugin.Name));
237-
Log.Exception("PluginsManager", "An error occurred while downloading plugin", e);
238237
// force close progress box
239238
Application.Current.Dispatcher.Invoke(() =>
240239
{
@@ -244,6 +243,13 @@ internal async Task InstallOrUpdateAsync(UserPlugin plugin)
244243
prgBox = null;
245244
}
246245
});
246+
247+
// show error message
248+
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"),
249+
string.Format(Context.API.GetTranslation("plugin_pluginsmanager_install_error_subtitle"),
250+
plugin.Name));
251+
Log.Exception("PluginsManager", "An error occurred while downloading plugin", e);
252+
247253
return;
248254
}
249255

0 commit comments

Comments
 (0)