Fix: Event session cold-start bug - presentations/presenters now load on first render
CRITICAL BUG FIX: Session view required 1-2 manual refreshes to display presentations and presenters when IndexedDB was empty. Root Cause: - Nested loaders passed try_cache: false, preventing IDB writes - Missing microtask yields caused race conditions between IDB writes and liveQuery subscriptions Changes: - ae_events__event_session.ts: Preserve try_cache in nested loads - ae_events__event_presentation.ts: Block on presenter loads with await Promise.all() + preserve try_cache - ae_events__event_presenter.ts: Add microtask yield after IDB write Result: Presentations AND presenters now render correctly on first navigation without requiring manual page refresh.
This commit is contained in:
@@ -134,7 +134,7 @@ async function _refresh_presenter_li_background({ api_cfg, for_obj_type, for_obj
|
||||
const result_li = await api.get_ae_obj_li_v3({ api_cfg, obj_type: 'event_presenter', for_obj_type, for_obj_id, enabled, hidden, view, limit, offset, order_by_li, log_lvl });
|
||||
if (result_li) {
|
||||
const processed = await process_ae_obj__event_presenter_props({ obj_li: result_li, log_lvl });
|
||||
|
||||
|
||||
// String-Only ID Vision: Ensure linking ID is set for indexing
|
||||
processed.forEach((p) => {
|
||||
if (for_obj_type === 'event_presentation') {
|
||||
@@ -153,6 +153,10 @@ async function _refresh_presenter_li_background({ api_cfg, for_obj_type, for_obj
|
||||
|
||||
if (try_cache) {
|
||||
await db_save_ae_obj_li__ae_obj({ db_instance: db_events, table_name: 'presenter', obj_li: processed, properties_to_save, log_lvl });
|
||||
// CRITICAL FIX (2026-02-26): Yield to microtask queue so Dexie liveQuery observers
|
||||
// fire before we return. Without this, component-mounted liveQueries may subscribe
|
||||
// to IDB *before* the write completes, causing empty results on cold-start.
|
||||
await Promise.resolve();
|
||||
}
|
||||
|
||||
// Background nested loads for refreshed items (FIRE AND FORGET)
|
||||
|
||||
Reference in New Issue
Block a user