diff options
Diffstat (limited to 'packages/shared/src/stores/GlobalSettingsBase.ts')
-rw-r--r-- | packages/shared/src/stores/GlobalSettingsBase.ts | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/packages/shared/src/stores/GlobalSettingsBase.ts b/packages/shared/src/stores/GlobalSettingsBase.ts new file mode 100644 index 0000000..48092fd --- /dev/null +++ b/packages/shared/src/stores/GlobalSettingsBase.ts | |||
@@ -0,0 +1,61 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2022 Kristóf Marussy <kristof@marussy.com> | ||
3 | * | ||
4 | * This file is part of Sophie. | ||
5 | * | ||
6 | * Sophie is free software: you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU Affero General Public License as | ||
8 | * published by the Free Software Foundation, version 3. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU Affero General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU Affero General Public License | ||
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
17 | * | ||
18 | * SPDX-License-Identifier: AGPL-3.0-only | ||
19 | */ | ||
20 | |||
21 | import { | ||
22 | Instance, | ||
23 | types, | ||
24 | SnapshotIn, | ||
25 | SnapshotOut, | ||
26 | IAnyModelType, | ||
27 | } from 'mobx-state-tree'; | ||
28 | |||
29 | import { ThemeSource } from '../schemas'; | ||
30 | |||
31 | import ServiceBase from './ServiceBase'; | ||
32 | |||
33 | export function defineGlobalSettingsModel<TS extends IAnyModelType>( | ||
34 | service: TS, | ||
35 | ) { | ||
36 | return types.model('GlobalSettings', { | ||
37 | themeSource: types.optional( | ||
38 | types.enumeration(ThemeSource.options), | ||
39 | 'system', | ||
40 | ), | ||
41 | showLocationBar: false, | ||
42 | selectedService: types.safeReference(service), | ||
43 | }); | ||
44 | } | ||
45 | |||
46 | const GlobalSettingsBase = /* @__PURE__ */ (() => | ||
47 | defineGlobalSettingsModel(ServiceBase))(); | ||
48 | |||
49 | /* | ||
50 | eslint-disable-next-line @typescript-eslint/no-redeclare -- | ||
51 | Intentionally naming the type the same as the store definition. | ||
52 | */ | ||
53 | interface GlobalSettingsBase extends Instance<typeof GlobalSettingsBase> {} | ||
54 | |||
55 | export default GlobalSettingsBase; | ||
56 | |||
57 | export interface GlobalSettingsSnapshotIn | ||
58 | extends SnapshotIn<typeof GlobalSettingsBase> {} | ||
59 | |||
60 | export interface GlobalSettingsSnapshotOut | ||
61 | extends SnapshotOut<typeof GlobalSettingsBase> {} | ||