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.ts22
1 files changed, 20 insertions, 2 deletions
diff --git a/packages/main/src/stores/MainStore.ts b/packages/main/src/stores/MainStore.ts
index eaf5b3c..f0d6472 100644
--- a/packages/main/src/stores/MainStore.ts
+++ b/packages/main/src/stores/MainStore.ts
@@ -18,12 +18,21 @@
18 * SPDX-License-Identifier: AGPL-3.0-only 18 * SPDX-License-Identifier: AGPL-3.0-only
19 */ 19 */
20 20
21import { BrowserViewBounds } from '@sophie/shared'; 21import { BrowserViewBounds, service } from '@sophie/shared';
22import { applySnapshot, Instance, types } from 'mobx-state-tree'; 22import {
23 applySnapshot,
24 Instance,
25 resolveIdentifier,
26 types,
27} from 'mobx-state-tree';
28
29import { getLogger } from '../utils/log';
23 30
24import type { Config } from './Config.js'; 31import type { Config } from './Config.js';
25import { sharedStore } from './SharedStore'; 32import { sharedStore } from './SharedStore';
26 33
34const log = getLogger('mainStore');
35
27export const mainStore = types 36export const mainStore = types
28 .model('MainStore', { 37 .model('MainStore', {
29 browserViewBounds: types.optional( 38 browserViewBounds: types.optional(
@@ -43,6 +52,15 @@ export const mainStore = types
43 }, 52 },
44 })) 53 }))
45 .actions((self) => ({ 54 .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 },
46 setBrowserViewBounds(bounds: BrowserViewBounds): void { 64 setBrowserViewBounds(bounds: BrowserViewBounds): void {
47 applySnapshot(self.browserViewBounds, bounds); 65 applySnapshot(self.browserViewBounds, bounds);
48 }, 66 },