From ede3747a1d5ef1dd9a6d74ba9600ca4f9bc452ed Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sun, 26 Dec 2021 00:27:39 +0100 Subject: refactor: Simplify browserViewBounds handling --- packages/main/src/index.ts | 2 +- packages/main/src/stores/RootStore.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'packages/main/src') diff --git a/packages/main/src/index.ts b/packages/main/src/index.ts index 22ae8e2..a135902 100644 --- a/packages/main/src/index.ts +++ b/packages/main/src/index.ts @@ -178,7 +178,7 @@ function createWindow(): Promise { browserView.webContents.userAgent = userAgent; autorun(() => { - browserView.setBounds(store.shared.browserViewBounds); + browserView.setBounds(store.browserViewBounds); }); mainWindow.setBrowserView(browserView); diff --git a/packages/main/src/stores/RootStore.ts b/packages/main/src/stores/RootStore.ts index 9d138ce..c09cd4a 100644 --- a/packages/main/src/stores/RootStore.ts +++ b/packages/main/src/stores/RootStore.ts @@ -27,10 +27,16 @@ import { } from '@sophie/shared'; export const rootStore = types.model('RootStore', { + browserViewBounds: types.model("BrowserViewBoundsStore", { + x: 0, + y: 0, + width: 0, + height: 0, + }), shared: sharedStore, }).actions((self) => ({ setBrowserViewBounds(bounds: BrowserViewBounds) { - applySnapshot(self.shared.browserViewBounds, bounds); + applySnapshot(self.browserViewBounds, bounds); }, setPaletteMode(mode: PaletteMode) { self.shared.shouldUseDarkColors = mode === 'dark'; @@ -41,6 +47,7 @@ export interface RootStore extends Instance {} export function createRootStore(): RootStore { return rootStore.create({ + browserViewBounds: {}, shared: emptySharedStore, }); } -- cgit v1.2.3-70-g09d2