perf(events): refactor load functions to be non-blocking

- Eliminated blocking 'await' calls in '+page.ts' for main Events, Session, Location, and Presenter views.
- Implemented Stale-While-Revalidate (SWR) pattern: pages now render instantly using cached IndexedDB data while API refreshes run in the background.
- Removed expensive sequential loops in load functions, allowing the reactive UI (via LiveQuery) to handle data arrival as background tasks complete.
This commit is contained in:
Scott Idem
2026-01-27 12:25:35 -05:00
parent 30413e32d2
commit 9655604d86
4 changed files with 54 additions and 122 deletions

View File

@@ -17,45 +17,33 @@ export async function load({ params, parent }) {
// console.log(`ae_acct = `, ae_acct);
const event_presenter_id = params.presenter_id;
// if (!event_presenter_id) {
// console.log(`ae events_pres_mgmt presenter [presenter_id] +page.ts: The event_presenter_id was not found in the params.presenter_id!!!`);
// return false;
// }
ae_acct.slct.event_presenter_id = event_presenter_id;
if (browser) {
// Load event presenter object
const load_event_presenter_obj = events_func.load_ae_obj_id__event_presenter({
if (log_lvl) console.log(`ae_events [presenter_id] +page.ts (Non-Blocking Refresh)`);
// OPTIMIZATION: Fire these in the background without 'await'.
// The Presenter View components use LiveQuery/Dexie and will update
// automatically once these background tasks complete.
// 1. Refresh the presenter object
events_func.load_ae_obj_id__event_presenter({
api_cfg: ae_acct.api,
event_presenter_id: event_presenter_id,
try_cache: true,
log_lvl: log_lvl
});
ae_acct.slct.event_presenter_obj = await load_event_presenter_obj;
// Load event files for the presenter
const load_event_file_obj_li = await events_func
.load_ae_obj_li__event_file({
api_cfg: ae_acct.api,
for_obj_type: 'event_presenter',
for_obj_id: event_presenter_id,
enabled: 'all',
hidden: 'all',
limit: 50,
try_cache: true
})
.then((event_file_obj_li) => {
if (log_lvl) {
console.log(`event_file_obj_li = `, event_file_obj_li);
}
return event_file_obj_li;
});
if (log_lvl) {
console.log(`load_event_file_obj_li = `, load_event_file_obj_li);
}
ae_acct.slct.event_file_obj_li = load_event_file_obj_li;
// 2. Refresh files for the presenter
events_func.load_ae_obj_li__event_file({
api_cfg: ae_acct.api,
for_obj_type: 'event_presenter',
for_obj_id: event_presenter_id,
enabled: 'all',
hidden: 'all',
limit: 150,
try_cache: true
});
}
// WARNING: Precaution against shared data between sites and presentations.