diff options
author | Kristóf Marussy <kristof@marussy.com> | 2021-12-26 00:27:39 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2021-12-26 00:36:24 +0100 |
commit | ede3747a1d5ef1dd9a6d74ba9600ca4f9bc452ed (patch) | |
tree | cd5b779f76d3c4e6a77865bbe13e0dc85deb0af1 /packages/main/src | |
parent | feat: Disable main window devtools in production (diff) | |
download | sophie-ede3747a1d5ef1dd9a6d74ba9600ca4f9bc452ed.tar.gz sophie-ede3747a1d5ef1dd9a6d74ba9600ca4f9bc452ed.tar.zst sophie-ede3747a1d5ef1dd9a6d74ba9600ca4f9bc452ed.zip |
refactor: Simplify browserViewBounds handling
Diffstat (limited to 'packages/main/src')
-rw-r--r-- | packages/main/src/index.ts | 2 | ||||
-rw-r--r-- | packages/main/src/stores/RootStore.ts | 9 |
2 files changed, 9 insertions, 2 deletions
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<unknown> { | |||
178 | 178 | ||
179 | browserView.webContents.userAgent = userAgent; | 179 | browserView.webContents.userAgent = userAgent; |
180 | autorun(() => { | 180 | autorun(() => { |
181 | browserView.setBounds(store.shared.browserViewBounds); | 181 | browserView.setBounds(store.browserViewBounds); |
182 | }); | 182 | }); |
183 | mainWindow.setBrowserView(browserView); | 183 | mainWindow.setBrowserView(browserView); |
184 | 184 | ||
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 { | |||
27 | } from '@sophie/shared'; | 27 | } from '@sophie/shared'; |
28 | 28 | ||
29 | export const rootStore = types.model('RootStore', { | 29 | export const rootStore = types.model('RootStore', { |
30 | browserViewBounds: types.model("BrowserViewBoundsStore", { | ||
31 | x: 0, | ||
32 | y: 0, | ||
33 | width: 0, | ||
34 | height: 0, | ||
35 | }), | ||
30 | shared: sharedStore, | 36 | shared: sharedStore, |
31 | }).actions((self) => ({ | 37 | }).actions((self) => ({ |
32 | setBrowserViewBounds(bounds: BrowserViewBounds) { | 38 | setBrowserViewBounds(bounds: BrowserViewBounds) { |
33 | applySnapshot(self.shared.browserViewBounds, bounds); | 39 | applySnapshot(self.browserViewBounds, bounds); |
34 | }, | 40 | }, |
35 | setPaletteMode(mode: PaletteMode) { | 41 | setPaletteMode(mode: PaletteMode) { |
36 | self.shared.shouldUseDarkColors = mode === 'dark'; | 42 | self.shared.shouldUseDarkColors = mode === 'dark'; |
@@ -41,6 +47,7 @@ export interface RootStore extends Instance<typeof rootStore> {} | |||
41 | 47 | ||
42 | export function createRootStore(): RootStore { | 48 | export function createRootStore(): RootStore { |
43 | return rootStore.create({ | 49 | return rootStore.create({ |
50 | browserViewBounds: {}, | ||
44 | shared: emptySharedStore, | 51 | shared: emptySharedStore, |
45 | }); | 52 | }); |
46 | } | 53 | } |