aboutsummaryrefslogtreecommitdiffstats
path: root/packages/main/src/stores/GlobalSettings.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/main/src/stores/GlobalSettings.ts')
-rw-r--r--packages/main/src/stores/GlobalSettings.ts22
1 files changed, 20 insertions, 2 deletions
diff --git a/packages/main/src/stores/GlobalSettings.ts b/packages/main/src/stores/GlobalSettings.ts
index 0a54aa3..7bbc089 100644
--- a/packages/main/src/stores/GlobalSettings.ts
+++ b/packages/main/src/stores/GlobalSettings.ts
@@ -22,12 +22,30 @@ import {
22 GlobalSettings as GlobalSettingsBase, 22 GlobalSettings as GlobalSettingsBase,
23 ThemeSource, 23 ThemeSource,
24} from '@sophie/shared'; 24} from '@sophie/shared';
25import { Instance } from 'mobx-state-tree'; 25import { Instance, resolveIdentifier, types } from 'mobx-state-tree';
26 26
27const GlobalSettings = GlobalSettingsBase.actions((self) => ({ 27import { getLogger } from '../utils/log';
28import overrideProps from '../utils/overrideProps';
29
30import Service from './Service';
31
32const log = getLogger('sharedStore');
33
34const GlobalSettings = overrideProps(GlobalSettingsBase, {
35 selectedService: types.safeReference(Service),
36}).actions((self) => ({
28 setThemeSource(mode: ThemeSource): void { 37 setThemeSource(mode: ThemeSource): void {
29 self.themeSource = mode; 38 self.themeSource = mode;
30 }, 39 },
40 setSelectedServiceId(serviceId: string): void {
41 const serviceInstance = resolveIdentifier(Service, self, serviceId);
42 if (serviceInstance === undefined) {
43 log.warn('Trying to select unknown service', serviceId);
44 return;
45 }
46 self.selectedService = serviceInstance;
47 log.debug('Selected service', serviceId);
48 },
31})); 49}));
32 50
33/* 51/*