aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared/src/stores/Config.ts
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2021-12-26 19:59:04 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2021-12-26 20:02:08 +0100
commit4ef4306cf401829905f764845ed78ac072fb94b6 (patch)
tree980a91a11cb1ac5f730d72c385e542edd0617d82 /packages/shared/src/stores/Config.ts
parentrefactor: Clarify main process architecture (diff)
downloadsophie-4ef4306cf401829905f764845ed78ac072fb94b6.tar.gz
sophie-4ef4306cf401829905f764845ed78ac072fb94b6.tar.zst
sophie-4ef4306cf401829905f764845ed78ac072fb94b6.zip
refactor: Make all stores optional
This reduces boilerplate and helps with config file robustness: if a field is missing from the config file, it will be replaced with its default value.
Diffstat (limited to 'packages/shared/src/stores/Config.ts')
-rw-r--r--packages/shared/src/stores/Config.ts8
1 files changed, 2 insertions, 6 deletions
diff --git a/packages/shared/src/stores/Config.ts b/packages/shared/src/stores/Config.ts
index 1a9f924..432945c 100644
--- a/packages/shared/src/stores/Config.ts
+++ b/packages/shared/src/stores/Config.ts
@@ -27,14 +27,10 @@ import {
27 27
28import { themeSource } from '../schemas'; 28import { themeSource } from '../schemas';
29 29
30export const config = types.model("Config", { 30export const config = types.model('Config', {
31 themeSource: types.enumeration(themeSource.options), 31 themeSource: types.optional(types.enumeration(themeSource.options), 'system'),
32}); 32});
33 33
34export const defaultConfig: ConfigSnapshotIn = {
35 themeSource: 'system',
36};
37
38export interface Config extends Instance<typeof config> {} 34export interface Config extends Instance<typeof config> {}
39 35
40export interface ConfigSnapshotIn extends SnapshotIn<typeof config> {} 36export interface ConfigSnapshotIn extends SnapshotIn<typeof config> {}