Display correct messages

Signed-off-by: Florian Grabmeier <flo.grabmeier@gmail.com>
This commit is contained in:
Florian Grabmeier 2023-11-22 14:49:43 +01:00
parent cb59b6b264
commit 8180c1cd40
2 changed files with 22 additions and 26 deletions

View file

@ -30,7 +30,7 @@
<system:String x:Key="plugin_pluginsmanager_update_alreadyexists">This plugin is already installed</system:String>
<system:String x:Key="plugin_pluginsmanager_update_failed_title">Plugin Manifest Download Failed</system:String>
<system:String x:Key="plugin_pluginsmanager_update_failed_subtitle">Please check if you can connect to github.com. This error means you may not be able to install or update plugins.</system:String>
<system:String x:Key="plugin_pluginsmanager_update_all_title">Update All Plugins</system:String>
<system:String x:Key="plugin_pluginsmanager_update_all_title">Update all plugins</system:String>
<system:String x:Key="plugin_pluginsmanager_update_all_subtitle">Would you like to update all plugins?</system:String>
<system:String x:Key="plugin_pluginsmanager_update_success_restart">Plugin {0} successfully updated. Restarting Flow, please wait...</system:String>
<system:String x:Key="plugin_pluginsmanager_install_unknown_source_warning_title">Installing from an unknown source</system:String>

View file

@ -308,25 +308,21 @@ namespace Flow.Launcher.Plugin.PluginsManager
Action = e =>
{
string message;
//TODO: display all plugins to be updated in the message
if (/*Settings.AutoRestartAfterChanging*/ false) // TODO: remove false
if (Settings.AutoRestartAfterChanging)
{
message = string.Format(Context.API.GetTranslation("plugin_pluginsmanager_update_all_subtitle"), "FlowLauncher will restart after updating all plugins.",
Environment.NewLine, Environment.NewLine);
message = "Would you like to update all plugins?\nFlowLauncher will restart after updating all plugins.\n";
}
else
{
message = string.Format(Context.API.GetTranslation("plugin_pluginsmanager_update_all_subtitle"),
Environment.NewLine);
message = "Would you like to update all plugins?\nFlowLauncher will restart after updating all plugins.\n";
}
if (MessageBox.Show(message,
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
Debug.Print("Looping through plugins to update");
foreach (var plugin in resultsForUpdate)
{
Debug.Print($"Updating {plugin.Name}");
var downloadToFilePath = Path.Combine(Path.GetTempPath(),
$"{plugin.Name}-{plugin.NewVersion}.zip");
@ -342,20 +338,6 @@ namespace Flow.Launcher.Plugin.PluginsManager
PluginManager.UpdatePlugin(plugin.PluginExistingMetadata, plugin.PluginNewUserPlugin, downloadToFilePath);
//TODO: fix
// if (Settings.AutoRestartAfterChanging)
// {
// Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
// string.Format(Context.API.GetTranslation("plugin_pluginsmanager_update_success_restart"),
// x.Name));
// Context.API.RestartApp();
// }
// else
// {
// Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
// string.Format(Context.API.GetTranslation("plugin_pluginsmanager_update_success_no_restart"),
// x.Name));
// }
}).ContinueWith(t =>
{
Log.Exception("PluginsManager", $"Update failed for {plugin.Name}",
@ -367,10 +349,24 @@ namespace Flow.Launcher.Plugin.PluginsManager
plugin.Name));
}, TaskContinuationOptions.OnlyOnFaulted);
}
Debug.Print("Finished updating all plugins");
return true; // User confirmed to update all plugins
if (Settings.AutoRestartAfterChanging)
{
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
string.Format(Context.API.GetTranslation("plugin_pluginsmanager_update_success_restart"),
"all"));
Context.API.RestartApp();
}
else
{
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
string.Format(Context.API.GetTranslation("plugin_pluginsmanager_update_success_no_restart"),
"all"));
}
return true;
}
return false; //user cancelled
return false;
},
ContextData = new UserPlugin()
};