Skip to content

Commit

Permalink
Set converDatum and display units after hydrate
Browse files Browse the repository at this point in the history
  • Loading branch information
wkramer committed Oct 24, 2024
1 parent cfd325b commit a27cbbc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/stores/userSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit a27cbbc

Please sign in to comment.