aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared/src/stores/GlobalSettingsBase.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/shared/src/stores/GlobalSettingsBase.ts')
-rw-r--r--packages/shared/src/stores/GlobalSettingsBase.ts64
1 files changed, 64 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..9d677c4
--- /dev/null
+++ b/packages/shared/src/stores/GlobalSettingsBase.ts
@@ -0,0 +1,64 @@
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
21import {
22 Instance,
23 types,
24 SnapshotIn,
25 SnapshotOut,
26 IAnyModelType,
27} from 'mobx-state-tree';
28
29import { ThemeSource } from '../schemas/ThemeSource.js';
30
31import ServiceBase from './ServiceBase.js';
32
33export const SYSTEM_LOCALE = 'system';
34
35export function defineGlobalSettingsModel<TS extends IAnyModelType>(
36 service: TS,
37) {
38 return types.model('GlobalSettings', {
39 language: SYSTEM_LOCALE,
40 themeSource: types.optional(
41 types.enumeration(ThemeSource.options),
42 'system',
43 ),
44 showLocationBar: false,
45 selectedService: types.safeReference(service),
46 });
47}
48
49const GlobalSettingsBase = /* @__PURE__ */ (() =>
50 defineGlobalSettingsModel(ServiceBase))();
51
52/*
53 eslint-disable-next-line @typescript-eslint/no-redeclare --
54 Intentionally naming the type the same as the store definition.
55*/
56interface GlobalSettingsBase extends Instance<typeof GlobalSettingsBase> {}
57
58export default GlobalSettingsBase;
59
60export interface GlobalSettingsSnapshotIn
61 extends SnapshotIn<typeof GlobalSettingsBase> {}
62
63export interface GlobalSettingsSnapshotOut
64 extends SnapshotOut<typeof GlobalSettingsBase> {}