fix(stores): merge defaults on PersistedState deserialize so new fields get defaults

runed PersistedState hydrates raw stored JSON without merging defaults, so any
field added after a user's first session is undefined rather than its default value.
Apply a shallow spread (defaults → stored) in the custom serializer for badges,
leads, and pres_mgmt stores so new fields always fall back to defaults for
existing sessions — without disrupting any previously saved preferences.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-06-08 20:47:25 -04:00
parent cc04411d23
commit 04f3b82d59
3 changed files with 20 additions and 3 deletions

View File

@@ -18,4 +18,9 @@
import { PersistedState } from 'runed';
import { leads_loc_defaults } from './ae_events_stores__leads_defaults';
export const leads_loc = new PersistedState('ae_leads_loc', leads_loc_defaults);
export const leads_loc = new PersistedState('ae_leads_loc', leads_loc_defaults, {
serializer: {
serialize: JSON.stringify,
deserialize: (raw: string) => ({ ...leads_loc_defaults, ...JSON.parse(raw) })
}
});