- Implemented aggressive room-wide background caching engine in LauncherBackgroundSync.svelte. - Added inc_file_li and inc_all_file_li support to Event and Event Location object loaders for total room coverage. - Switched to proven V1 download path (/hosted_file/) to resolve V3 CRUD binary delivery issues. - Optimized Electron bridge with download locking and flat-hash storage matching legacy 'perfect' logic. - Standardized all Electron IPC methods and parameters to snake_case. - Added visual sync progress indicator for room caching status.
86 lines
2.9 KiB
TypeScript
86 lines
2.9 KiB
TypeScript
/** @type {import('./$types').LayoutLoad} */
|
|
console.log(`Events - [event_id] launcher +layout.ts start`);
|
|
|
|
import { error } from '@sveltejs/kit';
|
|
import { browser } from '$app/environment';
|
|
import { events_func } from '$lib/ae_events_functions';
|
|
import type { ae_Event } from '$lib/types/ae_types';
|
|
|
|
export async function load({ params, parent, url }) {
|
|
// route
|
|
const log_lvl: number = 0;
|
|
|
|
const data = await parent();
|
|
// console.log(`ae events_pres_mgmt event [event_id] +page.ts data:`, data);
|
|
data.log_lvl = log_lvl;
|
|
|
|
const account_id = data.account_id;
|
|
let ae_acct = data[account_id];
|
|
|
|
if (!ae_acct) {
|
|
console.warn(`ae Events - [event_id] +layout.ts: Account ${account_id} not found in data. Initializing ghost acct.`);
|
|
ae_acct = {
|
|
api: data.ae_api || {},
|
|
slct: {
|
|
account_id: account_id
|
|
}
|
|
};
|
|
}
|
|
|
|
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: 'Events Pres Mgmt - Event ID not found'
|
|
});
|
|
}
|
|
|
|
ae_acct.slct.event_id = event_id;
|
|
|
|
if (browser) {
|
|
// console.log(`TEST URL Params`, params);
|
|
// console.log(`TEST URL`, url);
|
|
|
|
const load_event_obj: ae_Event | null = await events_func.load_ae_obj_id__event({
|
|
api_cfg: ae_acct.api,
|
|
event_id: event_id,
|
|
inc_file_li: true,
|
|
// inc_device_li: true,
|
|
inc_location_li: true,
|
|
inc_session_li: true,
|
|
// inc_badge_li: true,
|
|
inc_template_li: true,
|
|
log_lvl: log_lvl
|
|
// })
|
|
// .then((results) => {
|
|
// if (!results) {
|
|
// error(404, {
|
|
// message: 'Events - Event not found'
|
|
// });
|
|
// } else {
|
|
// // ae_acct.slct.event_obj = results;
|
|
// }
|
|
});
|
|
if (!load_event_obj) {
|
|
console.warn(`Events - [event_id] +layout.ts: Event ${event_id} not found via API or Cache.`);
|
|
// error(404, {
|
|
// message: 'Events - Event not found'
|
|
// });
|
|
} else {
|
|
console.log(`load_event_obj = `, load_event_obj);
|
|
ae_acct.slct.event_obj = load_event_obj;
|
|
// ae_acct.slct.event_device_obj_li = load_event_obj.event_device_obj_li;
|
|
ae_acct.slct.event_location_obj_li = load_event_obj.event_location_obj_li;
|
|
ae_acct.slct.event_session_obj_li = load_event_obj.event_session_obj_li;
|
|
ae_acct.slct.badge_template_obj_li = load_event_obj.event_badge_template_obj_li;
|
|
}
|
|
}
|
|
|
|
// WARNING: Precaution against shared data between sites and sessions.
|
|
data[account_id] = ae_acct;
|
|
|
|
return data;
|
|
}
|