Skip to content

Commit

Permalink
fix(Settings): changing start minimized does not reflect properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ArTiSTiX committed Dec 19, 2023
1 parent 467db03 commit ac4ebf7
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export function updateSetting(key: string, value: unknown) {
store.set(`settings.${key}`, value);
}

export function setStartupSetting() {
export function setStartupSetting(force = false) {
const settings = getSettings();
const loginItemSettings = app.getLoginItemSettings();

if (app.isPackaged && settings.general) {
if (!!settings.general?.launchAtStartup !== loginItemSettings.openAtLogin) {
if (force || !!settings.general?.launchAtStartup !== loginItemSettings.openAtLogin) {
app.setLoginItemSettings({
openAtLogin: !!settings?.general?.launchAtStartup,
openAsHidden: !!settings?.general?.startMinimized,
Expand Down Expand Up @@ -59,6 +59,13 @@ export function clearSettings() {
return store.clear();
}

store.onDidChange('settings', () => {
setStartupSetting();
store.onDidChange('settings', (newValue?: Settings, oldValue?: Settings) => {
if (
newValue &&
oldValue &&
(newValue.general?.launchAtStartup !== oldValue.general?.launchAtStartup ||
newValue.general?.startMinimized !== oldValue.general?.startMinimized)
) {
setStartupSetting(true);
}
});

0 comments on commit ac4ebf7

Please sign in to comment.