perf(hydration): implement non-blocking load path for Launcher and Sessions
- Implemented SWR pattern for session loading in ae_events__event_session.ts. - Refactored Launcher layouts (+layout.ts and +page.ts) to fire background refreshes instead of awaiting API calls. - Removed redundant blocking logic to ensure instant UI rendering from Dexie cache.
This commit is contained in:
@@ -28,102 +28,27 @@ export async function load({ params, parent, url }) {
|
||||
// console.log(`ae_acct = `, ae_acct);
|
||||
|
||||
const event_id = params.event_id;
|
||||
// if (!event_id) {
|
||||
// console.log(`ae Events - [event_id] +page.ts: The event_id was not found in the params.event_id!!!`);
|
||||
// error(404, {
|
||||
// message: 'Event ID not found'
|
||||
// });
|
||||
// }
|
||||
|
||||
// ae_acct.slct.event_id = event_id;
|
||||
|
||||
// let load_event_obj = events_func.handle_load_ae_obj_id__event({
|
||||
// api_cfg: ae_acct.api, event_id: event_id, try_cache: true
|
||||
// });
|
||||
|
||||
// ae_acct.slct.event_obj = await load_event_obj;
|
||||
|
||||
if (browser) {
|
||||
console.log(`ae_events Launcher - [event_id] launcher +layout.ts start`);
|
||||
if (log_lvl) console.log(`ae_events Launcher - [event_id] launcher +layout.ts (Non-Blocking)`);
|
||||
|
||||
// Load event object again, but with the event file list
|
||||
// let load_event_obj = events_func.load_ae_obj_id__event({
|
||||
// api_cfg: ae_acct.api,
|
||||
// event_id: event_id,
|
||||
// inc_file_li: true,
|
||||
// log_lvl: log_lvl
|
||||
// })
|
||||
// .then((results) => {
|
||||
// if (!results) {
|
||||
// error(404, {
|
||||
// message: 'Events Launcher - Event not found'
|
||||
// });
|
||||
// } else {
|
||||
// // ae_acct.slct.event_obj = results;
|
||||
// }
|
||||
// });
|
||||
|
||||
const load_event_device_obj_li = events_func.load_ae_obj_li__event_device({
|
||||
// OPTIMIZATION: Fire these in the background without 'await'.
|
||||
// The UI components (menu, session_view) already use LiveQuery/Dexie
|
||||
// and will automatically update when these background tasks save to IDB.
|
||||
events_func.load_ae_obj_li__event_device({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
log_lvl: log_lvl
|
||||
log_lvl: 0
|
||||
});
|
||||
|
||||
const load_event_file_obj_li = events_func.load_ae_obj_li__event_file({
|
||||
events_func.load_ae_obj_li__event_file({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
log_lvl: log_lvl
|
||||
log_lvl: 0
|
||||
});
|
||||
|
||||
// let load_event_obj = events_func.load_ae_obj_id__event({
|
||||
// api_cfg: ae_acct.api, event_id: event_id, try_cache: true, log_lvl: 1
|
||||
// });
|
||||
// console.log(`load_event_obj = `, load_event_obj);
|
||||
// ae_acct.slct.event_obj = load_event_obj;
|
||||
|
||||
// let load_event_session_obj_li = events_func.load_ae_obj_li__event_session({
|
||||
// api_cfg: ae_acct.api,
|
||||
// for_obj_type: 'event',
|
||||
// for_obj_id: event_id,
|
||||
// params: {qry__enabled: 'enabled', qry__hidden: 'all', qry__limit: 200},
|
||||
// try_cache: true,
|
||||
// log_lvl: 1
|
||||
// });
|
||||
// console.log(`load_event_session_obj_li = `, load_event_session_obj_li);
|
||||
// ae_acct.slct.event_session_obj_li = load_event_session_obj_li;
|
||||
|
||||
// let load_event_location_obj_li = events_func.load_ae_obj_li__event_location({
|
||||
// api_cfg: ae_acct.api,
|
||||
// for_obj_type: 'event',
|
||||
// for_obj_id: event_id,
|
||||
// params: {qry__enabled: 'enabled', qry__hidden: 'all', qry__limit: 200},
|
||||
// try_cache: true,
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
// console.log(`load_event_location_obj_li = `, load_event_location_obj_li);
|
||||
// ae_acct.slct.event_location_obj_li = load_event_location_obj_li;
|
||||
|
||||
// let event_session_id = url.searchParams.get('session_id');
|
||||
// if (event_session_id) {
|
||||
// let load_event_session_obj = events_func.load_ae_obj_id__event_session({
|
||||
// api_cfg: ae_acct.api,
|
||||
// event_session_id: event_session_id,
|
||||
// inc_file_li: true,
|
||||
// inc_presentation_li: true,
|
||||
// inc_presenter_li: true,
|
||||
// try_cache: true,
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
// ae_acct.slct.event_session_id = event_session_id;
|
||||
// console.log(`load_event_session_obj = `, load_event_session_obj);
|
||||
// ae_acct.slct.event_session_obj = load_event_session_obj;
|
||||
// }
|
||||
}
|
||||
|
||||
// WARNING: Precaution against shared data between sites and sessions.
|
||||
// data[account_id] = ae_acct;
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -43,57 +43,23 @@ export async function load({ params, parent, url }) {
|
||||
event_location_id
|
||||
);
|
||||
}
|
||||
// Load event_session object
|
||||
// let load_event_session_obj_li = await events_func.load_ae_obj_li__event_session({
|
||||
const load_event_session_obj_li = events_func
|
||||
.load_ae_obj_li__event_session({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
inc_file_li: true, // Only include files directly under the session?
|
||||
inc_all_file_li: true, // Also include files under presentations and presenters as well?
|
||||
inc_presentation_li: true,
|
||||
inc_presenter_li: true,
|
||||
enabled: 'enabled',
|
||||
hidden: 'all',
|
||||
limit: 150,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.finally(() => {
|
||||
// console.log(`load_event_session_obj_li = `, load_event_session_obj_li);
|
||||
// ae_acct.trig.event_session_obj_li = false;
|
||||
});
|
||||
ae_acct.slct.event_session_obj_li = load_event_session_obj_li;
|
||||
// console.log(`ae_acct.slct.event_session_obj_li = `, ae_acct.slct.event_session_obj_li);
|
||||
|
||||
// let id_li__event_session = [];
|
||||
|
||||
// let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
|
||||
|
||||
// for (let i = 0; i < load_event_session_obj_li.length; i++) {
|
||||
// let event_session_obj = load_event_session_obj_li[i];
|
||||
// let event_session_id = event_session_obj.event_session_id;
|
||||
// tmp_li.push(event_session_id);
|
||||
// }
|
||||
// id_li__event_session = tmp_li;
|
||||
// console.log(`id_li__event_session:`, id_li__event_session);
|
||||
// ae_acct.slct.id_li__event_session = id_li__event_session;
|
||||
|
||||
// This should only be needed if the session ID passed is not part of the location sessions.
|
||||
// let event_session_id = url.searchParams.get('session_id');
|
||||
// if (event_session_id) {
|
||||
// let load_event_session_obj = await events_func.load_ae_obj_id__event_session({
|
||||
// api_cfg: ae_acct.api,
|
||||
// event_session_id: event_session_id,
|
||||
// inc_file_li: true,
|
||||
// inc_presentation_li: true,
|
||||
// inc_presenter_li: true,
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
// ae_acct.slct.event_session_id = event_session_id;
|
||||
// console.log(`load_event_session_obj = `, load_event_session_obj);
|
||||
// ae_acct.slct.event_session_obj = load_event_session_obj;
|
||||
// }
|
||||
|
||||
// OPTIMIZATION: Fire the session list refresh in the background.
|
||||
// The Launcher components already use liveQuery to watch Dexie,
|
||||
// so they will update automatically once this background task finishes.
|
||||
events_func.load_ae_obj_li__event_session({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
inc_file_li: true,
|
||||
inc_all_file_li: true,
|
||||
inc_presentation_li: true,
|
||||
inc_presenter_li: true,
|
||||
enabled: 'enabled',
|
||||
hidden: 'all',
|
||||
limit: 150,
|
||||
log_lvl: 0
|
||||
});
|
||||
} else {
|
||||
console.log(`ae pres_mgmt launcher [slug] +page.ts: browser = false or location_id missing`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user