Four fixes found while tracing why Manager-saved Config page changes (QR, POC column, etc.) weren't reliably reaching pres_mgmt_loc: 1. Config page save was a race, not deterministic. The save handler only called load_ae_obj_id__event() (SWR — returns stale Dexie cache immediately, refreshes in the background, not awaited) and assumed that "picked up the new config." It never called sync_config__event_pres_mgmt() itself. Now calls it directly with the just-saved draft, so the editing browser updates instantly with no race. Kept the load_ae_obj_id__event() call (default try_cache: true) for propagating to other browsers/tabs via Dexie — do not pass try_cache: false there, that skips the Dexie write entirely. 2. Removed the dead "Lock Config" Sync/Unlink toggle in the sign-in panel (e_app_access_type.svelte). It wrote to four fields ($ae_loc.lock_config/sync_local_config, pres_mgmt_loc.current.lock_config/sync_local_config) that are never read anywhere (confirmed via full-repo grep), and confusingly shared a name with the real, functional "Lock Config" checkbox on the Pres Mgmt Config page. Removed the button and the now-orphaned lock_config/sync_local_config fields from PresMgmtLocState. 3. show__launcher_link was never assigned by sync_config__event_pres_mgmt() — only its inverse hide__launcher_link was. The toggle button's `show__launcher_link || trusted_access` visibility gate (in 3 menu files) always collapsed to trusted-only, ignoring the admin's setting. Added the missing assignment. 4. AE_PRES_MGMT_LOC_VERSION was bumped to 2 this morning claiming it "forces a localStorage reset" — it didn't, because _check_and_wipe() was never wired up for ae_pres_mgmt_loc, and even if it had been, the store never wrote a __version field to compare. Fixed: the store's serializer now stamps __version, and store_versions.ts wires the check. Found and fixed the same bug already live in ae_leads_loc, except worse there — it was wiping leads users' local prefs on EVERY page load, not just once. All logged in PROJECT__AE_Events_PressMgmt_Config_Cleanup.md. svelte-check: 0 errors, 0 warnings. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
39 lines
1.7 KiB
TypeScript
39 lines
1.7 KiB
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';
|
|
import { AE_LEADS_LOC_VERSION } from './store_versions';
|
|
|
|
export const leads_loc = new PersistedState('ae_leads_loc', leads_loc_defaults, {
|
|
serializer: {
|
|
// Stamp __version on every write so store_versions.ts's _check_and_wipe() can
|
|
// detect a breaking schema change and clear stale browsers on next load. Found
|
|
// 2026-06-16: this was previously bare JSON.stringify with no __version field,
|
|
// which made _check_and_wipe('ae_leads_loc', ...) see undefined !== expected
|
|
// every time and wipe this store on EVERY page load. This import also guarantees
|
|
// store_versions.ts's wipe side-effect runs before this PersistedState reads
|
|
// from localStorage (ES module execution order).
|
|
serialize: (value) =>
|
|
JSON.stringify({ ...value, __version: AE_LEADS_LOC_VERSION }),
|
|
deserialize: (raw: string) => {
|
|
const { __version, ...stored } = JSON.parse(raw);
|
|
return { ...leads_loc_defaults, ...stored };
|
|
}
|
|
}
|
|
});
|