Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(electron): save AlwaysOnTop preferences to avoid setting insconsistencies #601

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/electron/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) => {
Expand Down
4 changes: 3 additions & 1 deletion app/electron/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type StoreProps = {
useNativeTitlebar?: boolean;
compactMode?: boolean;
openAtLogin?: boolean;
alwaysOnTop?: boolean;
};

/**
Expand All @@ -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<string, any> = Record<string, unknown>,
T extends Record<string, any> = Record<string, unknown>
> {
private store: ElectronStore<T>;
constructor(props: Options<T>) {
Expand Down Expand Up @@ -58,6 +59,7 @@ const store = new SafeStore<StoreProps>({
useNativeTitlebar: !isWindow(),
compactMode: false,
openAtLogin: false,
alwaysOnTop: false,
},
});

Expand Down
Loading