aboutsummaryrefslogtreecommitdiffstats
path: root/packages/main/src/stores/MainStore.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/main/src/stores/MainStore.ts')
-rw-r--r--packages/main/src/stores/MainStore.ts39
1 files changed, 13 insertions, 26 deletions
diff --git a/packages/main/src/stores/MainStore.ts b/packages/main/src/stores/MainStore.ts
index f0d6472..18f5bf9 100644
--- a/packages/main/src/stores/MainStore.ts
+++ b/packages/main/src/stores/MainStore.ts
@@ -18,21 +18,14 @@
18 * SPDX-License-Identifier: AGPL-3.0-only 18 * SPDX-License-Identifier: AGPL-3.0-only
19 */ 19 */
20 20
21import { BrowserViewBounds, service } from '@sophie/shared'; 21import type { BrowserViewBounds } from '@sophie/shared';
22import { 22import { applySnapshot, Instance, types } from 'mobx-state-tree';
23 applySnapshot,
24 Instance,
25 resolveIdentifier,
26 types,
27} from 'mobx-state-tree';
28 23
29import { getLogger } from '../utils/log'; 24import { GlobalSettings } from './GlobalSettings';
30 25import { Profile } from './Profile';
31import type { Config } from './Config.js'; 26import { Service } from './Service';
32import { sharedStore } from './SharedStore'; 27import { sharedStore } from './SharedStore';
33 28
34const log = getLogger('mainStore');
35
36export const mainStore = types 29export const mainStore = types
37 .model('MainStore', { 30 .model('MainStore', {
38 browserViewBounds: types.optional( 31 browserViewBounds: types.optional(
@@ -47,26 +40,20 @@ export const mainStore = types
47 shared: types.optional(sharedStore, {}), 40 shared: types.optional(sharedStore, {}),
48 }) 41 })
49 .views((self) => ({ 42 .views((self) => ({
50 get config(): Config { 43 get settings(): GlobalSettings {
51 return self.shared.config; 44 return self.shared.settings;
45 },
46 get profiles(): Profile[] {
47 return self.shared.profiles;
48 },
49 get services(): Service[] {
50 return self.shared.services;
52 }, 51 },
53 })) 52 }))
54 .actions((self) => ({ 53 .actions((self) => ({
55 setSelectedServiceId(serviceId: string): void {
56 const serviceInstance = resolveIdentifier(service, self, serviceId);
57 if (serviceInstance === undefined) {
58 log.warn('Trying to select unknown service', serviceId);
59 return;
60 }
61 self.shared.selectedService = serviceInstance;
62 log.debug('Selected service', serviceId);
63 },
64 setBrowserViewBounds(bounds: BrowserViewBounds): void { 54 setBrowserViewBounds(bounds: BrowserViewBounds): void {
65 applySnapshot(self.browserViewBounds, bounds); 55 applySnapshot(self.browserViewBounds, bounds);
66 }, 56 },
67 setShouldUseDarkColors(shouldUseDarkColors: boolean): void {
68 self.shared.shouldUseDarkColors = shouldUseDarkColors;
69 },
70 })); 57 }));
71 58
72export interface MainStore extends Instance<typeof mainStore> {} 59export interface MainStore extends Instance<typeof mainStore> {}