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>
27 lines
961 B
TypeScript
27 lines
961 B
TypeScript
/**
|
|
* ae_events_stores__leads.svelte.ts
|
|
*
|
|
* Svelte 5 PersistedState store for the Exhibitor Leads module local config.
|
|
* Replaces the `events_loc.leads` sub-object from the Svelte 4 persisted store.
|
|
*
|
|
* localStorage key: 'ae_leads_loc'
|
|
* Version gate: AE_LEADS_LOC_VERSION in store_versions.ts
|
|
*
|
|
* Session state (non-persisted) stays in `events_sess.leads` — same pattern as
|
|
* pres_mgmt and badges.
|
|
*
|
|
* Usage:
|
|
* import { leads_loc } from '$lib/stores/ae_events_stores__leads.svelte';
|
|
* leads_loc.current.auth_exhibit_kv // read
|
|
* leads_loc.current.tab[exhibit_id] = 'list' // write
|
|
*/
|
|
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, {
|
|
serializer: {
|
|
serialize: JSON.stringify,
|
|
deserialize: (raw: string) => ({ ...leads_loc_defaults, ...JSON.parse(raw) })
|
|
}
|
|
});
|