feat(offline): implement Dexie fallbacks and fix type stability in Events module

- Offline Resilience: Added local Dexie fallbacks to load_ae_obj_id__* and load_ae_obj_li__* functions for Events, Sessions, Locations, Exhibits, and Badges.
- Type Safety: Standardized ae_Event and ae_EventSession interfaces in ae_types.ts; resolved Promise assignment errors in load functions (+page.ts).
- Bug Fixes: Corrected duplication in ae_events__event_location.ts and ae_events__event_badge_template.ts; fixed missing try_cache parameters.
- UI Stability: Fixed Dexie LiveQuery subscription pattern in bulk print view and ensured proper property access in layout load functions.
This commit is contained in:
Scott Idem
2026-01-16 15:09:10 -05:00
parent 2db2aba6f9
commit 8b611e7875
11 changed files with 998 additions and 1521 deletions

View File

@@ -4,6 +4,7 @@
import { ae_api } from '$lib/stores/ae_stores';
import { events_slct } from '$lib/stores/ae_events_stores';
import Comp_badge_obj_view from '../[badge_id]/ae_comp__badge_obj_view.svelte';
import type { ae_EventBadge } from '$lib/types/ae_types';
interface Props {
data: any; // PageData from SvelteKit
@@ -17,8 +18,8 @@
let lq__filtered_badges = $derived(
liveQuery(async () => {
const filters: { printed_status?: string; type_code?: string } = {};
if (printed_status_filter) filters.printed_status = printed_status_filter;
const filters: { printed_status?: "all" | "printed" | "not_printed"; type_code?: string } = {};
if (printed_status_filter) filters.printed_status = printed_status_filter as any;
if (badge_type_code_filter) filters.type_code = badge_type_code_filter;
// Fetch badges using the search function, with a high limit for bulk printing
@@ -29,7 +30,7 @@
...filters,
log_lvl: 0
});
return result || [];
return (result || []) as ae_EventBadge[];
})
);
@@ -76,12 +77,10 @@
</a>
</div>
{#await lq__filtered_badges}
<p>Loading badges for printing...</p>
{:then badges_to_print}
{#if badges_to_print.length > 0}
{#if $lq__filtered_badges}
{#if $lq__filtered_badges.length > 0}
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
{#each badges_to_print as badge_obj (badge_obj.event_badge_id_random)}
{#each $lq__filtered_badges as badge_obj (badge_obj.event_badge_id_random)}
<div class="badge-print-container">
<Comp_badge_obj_view
{event_id}
@@ -96,7 +95,7 @@
{:else}
<p>No badges found matching your criteria for printing.</p>
{/if}
{:catch error}
<p class="text-error-500">Error loading badges: {error.message}</p>
{/await}
{:else}
<p>Loading badges for printing...</p>
{/if}
</section>

View File

@@ -30,7 +30,7 @@ export async function load({ params, parent }) {
if (browser) {
// Load event location object
const load_event_location_obj = events_func.load_ae_obj_id__event_location({
const load_event_location_obj = await events_func.load_ae_obj_id__event_location({
api_cfg: ae_acct.api,
event_location_id: event_location_id,
try_cache: true
@@ -39,71 +39,45 @@ export async function load({ params, parent }) {
ae_acct.slct.event_location_obj = load_event_location_obj;
// Load event sessions for the location
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,
enabled: 'all',
limit: 50,
log_lvl: log_lvl
})
.then((event_session_obj_li) => {
if (log_lvl) {
console.log(`event_session_obj_li = `, event_session_obj_li);
}
for (let index = 0; index < event_session_obj_li.length; index++) {
const event_session_obj = event_session_obj_li[index];
const event_session_id = event_session_obj.event_session_id_random;
const event_session_obj_li = await events_func.load_ae_obj_li__event_session({
api_cfg: ae_acct.api,
for_obj_type: 'event_location',
for_obj_id: event_location_id,
enabled: 'all',
limit: 50,
log_lvl: log_lvl
});
const load_event_presentation_obj_li =
events_func.load_ae_obj_li__event_presentation({
api_cfg: ae_acct.api,
for_obj_type: 'event_session',
for_obj_id: event_session_id,
enabled: 'all',
limit: 25,
log_lvl: log_lvl
});
if (log_lvl) {
console.log(
`load_event_presentation_obj_li = `,
load_event_presentation_obj_li
);
}
event_session_obj_li[index].event_presentation_li =
load_event_presentation_obj_li;
}
if (event_session_obj_li) {
for (let index = 0; index < event_session_obj_li.length; index++) {
const event_session_obj = event_session_obj_li[index];
const event_session_id = event_session_obj.event_session_id || event_session_obj.id;
return event_session_obj_li;
});
if (log_lvl) {
console.log(`load_event_session_obj_li = `, load_event_session_obj_li);
const load_event_presentation_obj_li = await events_func.load_ae_obj_li__event_presentation({
api_cfg: ae_acct.api,
for_obj_type: 'event_session',
for_obj_id: event_session_id,
enabled: 'all',
limit: 25,
log_lvl: log_lvl
});
event_session_obj_li[index].event_presentation_li = load_event_presentation_obj_li;
}
}
ae_acct.slct.event_session_obj_li = load_event_session_obj_li;
ae_acct.slct.event_session_obj_li = event_session_obj_li;
const load_event_file_obj_li = await events_func
.load_ae_obj_li__event_file({
api_cfg: ae_acct.api,
for_obj_type: 'event_location',
for_obj_id: event_location_id,
enabled: 'all',
hidden: 'all',
limit: 50,
log_lvl: log_lvl
})
.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);
}
const load_event_file_obj_li = await events_func.load_ae_obj_li__event_file({
api_cfg: ae_acct.api,
for_obj_type: 'event_location',
for_obj_id: event_location_id,
enabled: 'all',
hidden: 'all',
limit: 50,
log_lvl: log_lvl
});
ae_acct.slct.event_file_obj_li = load_event_file_obj_li;
const load_event_device_obj_li = events_func.load_ae_obj_li__event_device({
const load_event_device_obj_li = await events_func.load_ae_obj_li__event_device({
api_cfg: ae_acct.api,
for_obj_type: 'event_location',
for_obj_id: event_location_id,

View File

@@ -47,75 +47,50 @@ export async function load({ params, parent }) {
ae_acct.slct.event_session_obj = load_event_session_obj;
// Load event presentations for the session
const load_event_presentation_obj_li = events_func
.load_ae_obj_li__event_presentation({
api_cfg: ae_acct.api,
for_obj_type: 'event_session',
for_obj_id: event_session_id,
inc_presenter_li: true,
enabled: 'all',
hidden: 'all',
limit: 19,
// params: {},
try_cache: true,
log_lvl: 2
})
.then((event_presentation_obj_li) => {
if (log_lvl) {
console.log(`event_presentation_obj_li = `, event_presentation_obj_li);
}
for (let index = 0; index < event_presentation_obj_li?.length; index++) {
const event_presentation_obj = event_presentation_obj_li[index];
const event_presentation_id =
event_presentation_obj.event_presentation_id_random;
const event_presentation_obj_li = await events_func.load_ae_obj_li__event_presentation({
api_cfg: ae_acct.api,
for_obj_type: 'event_session',
for_obj_id: event_session_id,
inc_presenter_li: true,
enabled: 'all',
hidden: 'all',
limit: 19,
// params: {},
try_cache: true,
log_lvl: 2
});
const load_event_presenter_obj_li = events_func.load_ae_obj_li__event_presenter(
{
api_cfg: ae_acct.api,
for_obj_type: 'event_presentation',
for_obj_id: event_presentation_id,
enabled: 'all',
hidden: 'all',
limit: 19,
params: {},
try_cache: true,
log_lvl: 2
}
);
if (log_lvl) {
console.log(`load_event_presenter_obj_li = `, load_event_presenter_obj_li);
}
event_presentation_obj_li[index].event_presenter_li =
load_event_presenter_obj_li;
}
if (event_presentation_obj_li) {
for (let index = 0; index < event_presentation_obj_li.length; index++) {
const event_presentation_obj = event_presentation_obj_li[index];
const event_presentation_id = event_presentation_obj.event_presentation_id || event_presentation_obj.id;
return event_presentation_obj_li;
});
if (log_lvl) {
console.log(`load_event_presentation_obj_li = `, load_event_presentation_obj_li);
const load_event_presenter_obj_li = await events_func.load_ae_obj_li__event_presenter({
api_cfg: ae_acct.api,
for_obj_type: 'event_presentation',
for_obj_id: event_presentation_id,
enabled: 'all',
hidden: 'all',
limit: 19,
params: {},
try_cache: true,
log_lvl: 2
});
event_presentation_obj_li[index].event_presenter_li = load_event_presenter_obj_li;
}
}
ae_acct.slct.event_presentation_obj_li = load_event_presentation_obj_li;
ae_acct.slct.event_presentation_obj_li = event_presentation_obj_li;
// Load event files for the session
const load_event_file_obj_li = await events_func
.load_ae_obj_li__event_file({
api_cfg: ae_acct.api,
for_obj_type: 'event_session',
for_obj_id: event_session_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);
}
const load_event_file_obj_li = await events_func.load_ae_obj_li__event_file({
api_cfg: ae_acct.api,
for_obj_type: 'event_session',
for_obj_id: event_session_id,
enabled: 'all',
hidden: 'all',
limit: 50,
try_cache: true
});
ae_acct.slct.event_file_obj_li = load_event_file_obj_li;
}