diff options
Diffstat (limited to 'src/webapp/src/lib/stores/preferences.ts')
| -rw-r--r-- | src/webapp/src/lib/stores/preferences.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/webapp/src/lib/stores/preferences.ts b/src/webapp/src/lib/stores/preferences.ts new file mode 100644 index 0000000..e99f90d --- /dev/null +++ b/src/webapp/src/lib/stores/preferences.ts @@ -0,0 +1,34 @@ +import {StoreType, writable_persistent} from "@/lib/stores/persistent-store"; +import {storage_keys} from "@/lib/configuration"; +import type {IPreferences} from "@/lib/models/IPreferences"; +import {ApplicationTheme} from "@/lib/enums/ApplicationTheme"; +import {get} from "svelte/store"; + +const default_preferences = { + // remember to change default in index.html + theme: ApplicationTheme.LIGHT, + enable_site_report: true, +} as IPreferences; + +const preferences = writable_persistent({ + name: storage_keys.preferences, + options: { + store: StoreType.LOCAL, + compress: false + }, + initialState: default_preferences +}); + +export function set_site_report_state(enabled: boolean) { + const prefs = get(preferences); + prefs.enable_site_report = enabled; + preferences.set(prefs); +} + +export function set_theme(theme: ApplicationTheme) { + const prefs = get(preferences); + prefs.theme = theme; + preferences.set(prefs); +} + +export default preferences; |
