diff options
Diffstat (limited to 'packages/main/src/stores/GlobalSettings.ts')
-rw-r--r-- | packages/main/src/stores/GlobalSettings.ts | 22 |
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'; |
25 | import { Instance } from 'mobx-state-tree'; | 25 | import { Instance, resolveIdentifier, types } from 'mobx-state-tree'; |
26 | 26 | ||
27 | const GlobalSettings = GlobalSettingsBase.actions((self) => ({ | 27 | import { getLogger } from '../utils/log'; |
28 | import overrideProps from '../utils/overrideProps'; | ||
29 | |||
30 | import Service from './Service'; | ||
31 | |||
32 | const log = getLogger('sharedStore'); | ||
33 | |||
34 | const 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 | /* |