Skip to content

Commit

Permalink
Fix maximised setting
Browse files Browse the repository at this point in the history
  • Loading branch information
perry-mitchell committed Nov 3, 2023
1 parent 0b034cd commit 54250f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions source/main/services/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface Config {
browserPrivateKey: string | null;
browserPublicKey: string | null;
fileHostKey: null | string;
isMaximised: boolean;
preferences: Preferences;
selectedSource: null | string;
windowHeight: number;
Expand All @@ -29,13 +30,13 @@ const DEFAULT_CONFIG: Config = {
browserPrivateKey: null,
browserPublicKey: null,
fileHostKey: null,
isMaximised: false,
preferences: naiveClone(PREFERENCES_DEFAULT),
selectedSource: null,
windowHeight: 600,
windowWidth: 800,
windowX: null,
windowY: null,
isMaximize: false
windowY: null
};

export async function getConfigValue<K extends keyof Config>(key: K): Promise<Config[K]> {
Expand Down
16 changes: 8 additions & 8 deletions source/main/services/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export async function closeWindows(): Promise<void> {
}

async function createVaultWindow() {
const width = await getConfigValue<number>("windowWidth");
const height = await getConfigValue<number>("windowHeight");
const x = await getConfigValue<number>("windowX");
const y = await getConfigValue<number>("windowY");
const isMaximize = await getConfigValue<boolean>("isMaximize");
const width = await getConfigValue("windowWidth");
const height = await getConfigValue("windowHeight");
const x = await getConfigValue("windowX");
const y = await getConfigValue("windowY");
const isMaximised = await getConfigValue("isMaximised");
const config: BrowserWindowConstructorOptions = {
width,
height,
Expand All @@ -39,7 +39,7 @@ async function createVaultWindow() {
config.y = y;
}
const win = new BrowserWindow(config);
if (isMaximize) {
if (isMaximised) {
win.maximize();
}
enableWebContents(win.webContents);
Expand All @@ -53,11 +53,11 @@ async function createVaultWindow() {
);

win.on("maximize", async () => {
await setConfigValue("isMaximize", win.isMaximized());
await setConfigValue("isMaximised", win.isMaximized());
});

win.on("unmaximize", async () => {
await setConfigValue("isMaximize", win.isMaximized());
await setConfigValue("isMaximised", win.isMaximized());
});

win.on(
Expand Down

0 comments on commit 54250f4

Please sign in to comment.