diff options
Diffstat (limited to 'packages/shared/src/stores')
-rw-r--r-- | packages/shared/src/stores/Config.ts | 42 | ||||
-rw-r--r-- | packages/shared/src/stores/SharedStore.ts | 4 |
2 files changed, 46 insertions, 0 deletions
diff --git a/packages/shared/src/stores/Config.ts b/packages/shared/src/stores/Config.ts new file mode 100644 index 0000000..1a9f924 --- /dev/null +++ b/packages/shared/src/stores/Config.ts | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2021-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 | } from 'mobx-state-tree'; | ||
27 | |||
28 | import { themeSource } from '../schemas'; | ||
29 | |||
30 | export const config = types.model("Config", { | ||
31 | themeSource: types.enumeration(themeSource.options), | ||
32 | }); | ||
33 | |||
34 | export const defaultConfig: ConfigSnapshotIn = { | ||
35 | themeSource: 'system', | ||
36 | }; | ||
37 | |||
38 | export interface Config extends Instance<typeof config> {} | ||
39 | |||
40 | export interface ConfigSnapshotIn extends SnapshotIn<typeof config> {} | ||
41 | |||
42 | export interface ConfigSnapshotOut extends SnapshotOut<typeof config> {} | ||
diff --git a/packages/shared/src/stores/SharedStore.ts b/packages/shared/src/stores/SharedStore.ts index 9c7d5ad..9f0afb1 100644 --- a/packages/shared/src/stores/SharedStore.ts +++ b/packages/shared/src/stores/SharedStore.ts | |||
@@ -26,11 +26,15 @@ import { | |||
26 | SnapshotOut, | 26 | SnapshotOut, |
27 | } from 'mobx-state-tree'; | 27 | } from 'mobx-state-tree'; |
28 | 28 | ||
29 | import { config, defaultConfig } from './Config'; | ||
30 | |||
29 | export const sharedStore = types.model("SharedStore", { | 31 | export const sharedStore = types.model("SharedStore", { |
32 | config, | ||
30 | shouldUseDarkColors: true, | 33 | shouldUseDarkColors: true, |
31 | }); | 34 | }); |
32 | 35 | ||
33 | export const emptySharedStore: SharedStoreSnapshotIn = { | 36 | export const emptySharedStore: SharedStoreSnapshotIn = { |
37 | config: defaultConfig, | ||
34 | }; | 38 | }; |
35 | 39 | ||
36 | export interface SharedStore extends Instance<typeof sharedStore> {} | 40 | export interface SharedStore extends Instance<typeof sharedStore> {} |