mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Move settings save to post-confirmation for actions
Previously, `Context.API.SaveAppAllSettings()` was called unconditionally before user confirmation for shutdown, restart, and advanced restart actions. This change ensures settings are only saved if the user confirms the action by clicking "Yes" in the confirmation dialog. For all three functionalities: - Moved the settings save call inside the `if (result == MessageBoxResult.Yes)` block. - Retained the existing logic for executing the respective system commands, with checks for `EnableShutdownPrivilege()` to determine whether to use `PInvoke.ExitWindowsEx` or the `shutdown` command. This change prevents unnecessary settings saves when the user cancels the action.
This commit is contained in:
parent
e376da4482
commit
167570559f
1 changed files with 15 additions and 15 deletions
|
|
@ -210,16 +210,16 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
Localize.flowlauncher_plugin_sys_dlgtext_shutdown_computer(),
|
||||
Localize.flowlauncher_plugin_sys_shutdown_computer(),
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
|
||||
// Save settings before shutdown to avoid data loss
|
||||
Context.API.SaveAppAllSettings();
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
// Save settings before shutdown to avoid data loss
|
||||
Context.API.SaveAppAllSettings();
|
||||
|
||||
if (EnableShutdownPrivilege())
|
||||
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS.EWX_POWEROFF, REASON);
|
||||
else
|
||||
Process.Start("shutdown", "/s /t 0");
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
|
@ -234,16 +234,16 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
Localize.flowlauncher_plugin_sys_dlgtext_restart_computer(),
|
||||
Localize.flowlauncher_plugin_sys_restart_computer(),
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
|
||||
// Save settings before restart to avoid data loss
|
||||
Context.API.SaveAppAllSettings();
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
// Save settings before restart to avoid data loss
|
||||
Context.API.SaveAppAllSettings();
|
||||
|
||||
if (EnableShutdownPrivilege())
|
||||
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, REASON);
|
||||
else
|
||||
Process.Start("shutdown", "/r /t 0");
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
|
@ -258,16 +258,16 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
Localize.flowlauncher_plugin_sys_dlgtext_restart_computer_advanced(),
|
||||
Localize.flowlauncher_plugin_sys_restart_computer(),
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
|
||||
// Save settings before restart to avoid data loss
|
||||
Context.API.SaveAppAllSettings();
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
// Save settings before restart to avoid data loss
|
||||
Context.API.SaveAppAllSettings();
|
||||
|
||||
if (EnableShutdownPrivilege())
|
||||
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT | EXIT_WINDOWS_FLAGS.EWX_BOOTOPTIONS, REASON);
|
||||
else
|
||||
Process.Start("shutdown", "/r /o /t 0");
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue