From 4ef4306cf401829905f764845ed78ac072fb94b6 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sun, 26 Dec 2021 19:59:04 +0100 Subject: 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. --- packages/shared/src/stores/Config.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'packages/shared/src/stores/Config.ts') 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 { import { themeSource } from '../schemas'; -export const config = types.model("Config", { - themeSource: types.enumeration(themeSource.options), +export const config = types.model('Config', { + themeSource: types.optional(types.enumeration(themeSource.options), 'system'), }); -export const defaultConfig: ConfigSnapshotIn = { - themeSource: 'system', -}; - export interface Config extends Instance {} export interface ConfigSnapshotIn extends SnapshotIn {} -- cgit v1.2.3-70-g09d2