From a27cbbc4691bca178cba1cae306dce1ab2270100 Mon Sep 17 00:00:00 2001 From: Werner Kramer Date: Thu, 24 Oct 2024 12:27:20 +0200 Subject: [PATCH] Set converDatum and display units after hydrate --- src/stores/userSettings.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/stores/userSettings.ts b/src/stores/userSettings.ts index 0cb25796..c056035d 100644 --- a/src/stores/userSettings.ts +++ b/src/stores/userSettings.ts @@ -117,12 +117,20 @@ export const useUserSettingsStore = defineStore({ key: 'weboc-user-settings-v1.0.0', storage: window.localStorage, pick: ['items'], + afterHydrate: (context) => { + ['units.displayUnits', 'datum.verticalDatum'].forEach((id) => { + const item = context.store.items.find((item: UserSettingsItem) => item.id === id) + if (item) { + context.store.add(item) + } + }) + }, serializer: { serialize: (context) => { return JSON.stringify(context) }, - deserialize: (context) => { - const parsedState = JSON.parse(context) + deserialize: (data) => { + const parsedState = JSON.parse(data) const newState = [...defaultUserSettings] for (const prop of newState) { const storedProp = parsedState.items.find(