From edde809acdf850d0f7efe620211d5468025665d6 Mon Sep 17 00:00:00 2001 From: dubisdev Date: Wed, 31 Jan 2024 19:55:00 +0100 Subject: [PATCH] fix(electron): save AlwaysOnTop preferences to avoid setting insconsistencies --- app/electron/src/main.ts | 2 ++ app/electron/src/store.ts | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/electron/src/main.ts b/app/electron/src/main.ts index 2361fbd8..cf5b53fc 100644 --- a/app/electron/src/main.ts +++ b/app/electron/src/main.ts @@ -96,6 +96,7 @@ function createMainWindow() { frame: store.safeGet("useNativeTitlebar"), icon: getIcon(), backgroundColor: store.safeGet("isDarkMode") ? "#141e25" : "#fff", + alwaysOnTop: store.safeGet("alwaysOnTop"), webPreferences: { contextIsolation: true, backgroundThrottling: false, @@ -366,6 +367,7 @@ if (!onlySingleInstance) { ipcMain.on(SET_ALWAYS_ON_TOP, (e, { alwaysOnTop }) => { win?.setAlwaysOnTop(alwaysOnTop); + store.safeSet("alwaysOnTop", alwaysOnTop); }); ipcMain.on(SET_FULLSCREEN_BREAK, (e, args) => { diff --git a/app/electron/src/store.ts b/app/electron/src/store.ts index e5558246..d820ed34 100644 --- a/app/electron/src/store.ts +++ b/app/electron/src/store.ts @@ -9,6 +9,7 @@ type StoreProps = { useNativeTitlebar?: boolean; compactMode?: boolean; openAtLogin?: boolean; + alwaysOnTop?: boolean; }; /** @@ -17,7 +18,7 @@ type StoreProps = { * This also ensures that we can force calling the store safely. Though I have switched the names to safeGet and safeSet to make it more clear. */ class SafeStore< - T extends Record = Record, + T extends Record = Record > { private store: ElectronStore; constructor(props: Options) { @@ -58,6 +59,7 @@ const store = new SafeStore({ useNativeTitlebar: !isWindow(), compactMode: false, openAtLogin: false, + alwaysOnTop: false, }, });