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

@@ -22,50 +22,32 @@ export async function load({ parent }) {
}
if (browser) {
if (event_id) {
// let ae_params = {};
if (log_lvl) console.log(`ae_events +page.ts (Non-Blocking Refresh)`);
const load_event_obj_li = await events_func.load_ae_obj_id__event({
if (event_id) {
// Refresh the specific selected event
events_func.load_ae_obj_id__event({
api_cfg: ae_acct.api,
event_id: event_id,
log_lvl: log_lvl
});
ae_acct.slct.event_obj_li = load_event_obj_li;
}
const load_event_obj_li = await events_func.load_ae_obj_li__event({
// Refresh the list of events for the account
events_func.load_ae_obj_li__event({
api_cfg: ae_acct.api,
for_obj_type: 'account',
for_obj_id: account_id,
inc_session_li: true,
hidden: 'all', // 'not_hidden'
enabled: 'enabled',
// order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
limit: 25,
// params: ae_params,
try_cache: true,
log_lvl: log_lvl
});
ae_acct.slct.event_obj_li = load_event_obj_li;
}
parent_data[account_id] = ae_acct;
return parent_data;
// let ae_acct = parent_data[account_id];
// Should we limit these to event.conference = true?
// let load_event_obj_li = await events_func.load_ae_obj_li__event({
// api_cfg: ae_acct.api,
// account_id: account_id,
// params: {enabled: 'enabled', qry__limit: 25},
// try_cache: false,
// log_lvl: 1
// });
// ae_acct.slct.event_obj_li = load_event_obj_li;
// parent_data[account_id] = ae_acct;
// return parent_data;
}