Skip to content

Commit cecd90e

Browse files
committed
Refactor: Improve power action logic and property setter
- Add braces for better readability in shutdown/reboot logic (Main.cs). - Prevent redundant OnPropertyChanged calls in _skipPowerActionConfirmation setter (Settings.cs).
1 parent 2d7d025 commit cecd90e

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

Plugins/Flow.Launcher.Plugin.Sys/Main.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ private List<Result> Commands(Query query)
222222
Process.Start("shutdown", "/s /t 0");
223223
}
224224
return true;
225-
}
225+
}
226226
},
227227
new Result
228228
{
@@ -238,15 +238,15 @@ private List<Result> Commands(Query query)
238238
Localize.flowlauncher_plugin_sys_restart_computer(),
239239
MessageBoxButton.YesNo, MessageBoxImage.Warning);
240240

241-
if (result == MessageBoxResult.Yes)
242-
{
243-
Context.API.SaveAppAllSettings();
244-
if (EnableShutdownPrivilege())
245-
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, REASON);
246-
else
247-
Process.Start("shutdown", "/r /t 0");
248-
}
249-
return true;
241+
if (result == MessageBoxResult.Yes)
242+
{
243+
Context.API.SaveAppAllSettings();
244+
if (EnableShutdownPrivilege())
245+
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, REASON);
246+
else
247+
Process.Start("shutdown", "/r /t 0");
248+
}
249+
return true;
250250
}
251251
},
252252
new Result

Plugins/Flow.Launcher.Plugin.Sys/Settings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ public bool SkipPowerActionConfirmation
130130
get => _skipPowerActionConfirmation;
131131
set
132132
{
133+
if (_skipPowerActionConfirmation == value)
134+
{
135+
return;
136+
}
133137
_skipPowerActionConfirmation = value;
138+
OnPropertyChanged();
134139
}
135140
}
136141
}

0 commit comments

Comments
 (0)