diff --git a/documentation/SVELTE_DEXIE_GUIDE.md b/documentation/SVELTE_DEXIE_GUIDE.md index 1f52e35e..ac994ef3 100644 --- a/documentation/SVELTE_DEXIE_GUIDE.md +++ b/documentation/SVELTE_DEXIE_GUIDE.md @@ -92,6 +92,35 @@ export function createLiveQueryStore(query: () => T | Promise) { The `createLiveQueryStore` function creates a readable store that automatically updates whenever the data in the `friends` table changes. The `$friends` variable in the component will always contain the latest data from the database. +## Svelte 5 Binding Pitfalls + +### 1. `props_invalid_value` (The "Expression Binding" Error) +Svelte 5's `bind:` directive is more restrictive than previous versions. You can only bind to a simple **Identifier** or **MemberExpression**. + +**❌ Invalid Pattern (Causes Compile Error):** +Attempting to normalize a value *inside* the binding will fail. +```svelte + + +``` + +**✅ Correct Pattern:** +Ensure the source value is already normalized before binding, or use a reactive effect to handle the fallback. +```typescript +// Normalize in an effect or derivation +$effect(() => { + if ($events_slct.event_session_id === undefined) { + $events_slct.event_session_id = null; + } +}); +``` +```svelte + + +``` + +--- + ## Safe Data Processing for IndexedDB Sorting When preparing data for IndexedDB, especially when creating composite sort keys, it is critical to handle `null` or `undefined` values safely to prevent runtime crashes that can interrupt the data synchronization process. diff --git a/src/lib/ae_events/ae_events__event_session.ts b/src/lib/ae_events/ae_events__event_session.ts index eea880fd..6c2805f5 100644 --- a/src/lib/ae_events/ae_events__event_session.ts +++ b/src/lib/ae_events/ae_events__event_session.ts @@ -196,7 +196,12 @@ export async function load_ae_obj_li__event_session({ if (log_lvl) console.log(`✅ [Trace] load_ae_obj_li: CACHE HIT at ${elapsed}ms (${cached_li.length} items).`); // Background refresh (non-blocking) - _refresh_session_li_background({ api_cfg, for_obj_type, for_obj_id, inc_file_li, inc_all_file_li, inc_presentation_li, inc_presenter_li, enabled, hidden, limit, offset, order_by_li, try_cache, log_lvl: log_lvl > 1 ? log_lvl : 0 }); + _refresh_session_li_background({ + api_cfg, for_obj_type, for_obj_id, view, + inc_file_li, inc_all_file_li, inc_presentation_li, inc_presenter_li, + enabled, hidden, limit, offset, order_by_li, try_cache, + log_lvl: log_lvl > 1 ? log_lvl : 0 + }); return cached_li; } else if (log_lvl) { @@ -207,15 +212,15 @@ export async function load_ae_obj_li__event_session({ } } - return await _refresh_session_li_background({ api_cfg, for_obj_type, for_obj_id, inc_file_li, inc_all_file_li, inc_presentation_li, inc_presenter_li, enabled, hidden, limit, offset, order_by_li, try_cache, log_lvl }); + return await _refresh_session_li_background({ api_cfg, for_obj_type, for_obj_id, view, inc_file_li, inc_all_file_li, inc_presentation_li, inc_presenter_li, enabled, hidden, limit, offset, order_by_li, try_cache, log_lvl }); } -async function _refresh_session_li_background({ api_cfg, for_obj_type, for_obj_id, inc_file_li, inc_all_file_li, inc_presentation_li, inc_presenter_li, enabled, hidden, limit, offset, order_by_li, try_cache, log_lvl }: any) { +async function _refresh_session_li_background({ api_cfg, for_obj_type, for_obj_id, view, inc_file_li, inc_all_file_li, inc_presentation_li, inc_presenter_li, enabled, hidden, limit, offset, order_by_li, try_cache, log_lvl }: any) { const start_time = performance.now(); if (typeof navigator !== 'undefined' && !navigator.onLine) return []; try { - if (log_lvl) console.log(`📡 [Trace] _refresh_session_li: API Fetching for=${for_obj_type}:${for_obj_id}`); - const result_li = await api.get_ae_obj_li_v3({ api_cfg, obj_type: 'event_session', for_obj_type, for_obj_id, enabled, hidden, limit, offset, order_by_li, log_lvl }); + if (log_lvl) console.log(`📡 [Trace] _refresh_session_li: API Fetching for=${for_obj_type}:${for_obj_id} (view=${view})`); + const result_li = await api.get_ae_obj_li_v3({ api_cfg, obj_type: 'event_session', for_obj_type, for_obj_id, view, enabled, hidden, limit, offset, order_by_li, log_lvl }); if (result_li) { const processed = await process_ae_obj__event_session_props({ obj_li: result_li, log_lvl }); diff --git a/src/lib/stores/ae_events_stores.ts b/src/lib/stores/ae_events_stores.ts index 712703ec..ef0f591a 100644 --- a/src/lib/stores/ae_events_stores.ts +++ b/src/lib/stores/ae_events_stores.ts @@ -667,6 +667,7 @@ const events_slct_obj_template: key_val = { event_presenter_obj: {}, session_id: null, + event_session_id: null, session_obj: {}, session_obj_li: [], event_session_obj: {}, diff --git a/src/routes/events/[event_id]/(launcher)/launcher/[event_location_id]/+page.ts b/src/routes/events/[event_id]/(launcher)/launcher/[event_location_id]/+page.ts index 6f13242b..28dc153c 100644 --- a/src/routes/events/[event_id]/(launcher)/launcher/[event_location_id]/+page.ts +++ b/src/routes/events/[event_id]/(launcher)/launcher/[event_location_id]/+page.ts @@ -59,6 +59,7 @@ export async function load({ params, parent, url }) { inc_presenter_li: true, enabled: 'enabled', hidden: 'all', + view: 'alt', // Standardized View for file counts and extended metadata limit: 150, log_lvl: 0 }); diff --git a/src/routes/events/[event_id]/(launcher)/launcher_file_cont.svelte b/src/routes/events/[event_id]/(launcher)/launcher_file_cont.svelte index b6f4a6e3..e4072e43 100644 --- a/src/routes/events/[event_id]/(launcher)/launcher_file_cont.svelte +++ b/src/routes/events/[event_id]/(launcher)/launcher_file_cont.svelte @@ -92,6 +92,7 @@ async function handle_open_file() { if (log_lvl) console.log('*** handle_open_file() ***'); + if (open_file_clicked) return; // Hard Guard: Already processing $events_slct.event_file_id = event_file_id; $events_slct.event_file_obj = event_file_obj; @@ -107,7 +108,8 @@ const exists = await native.check_hash_file_cache({ cache_root, - hash: event_file_obj.hash_sha256 + hash: event_file_obj.hash_sha256, + verify_hash: true // Hardened: Trust No One! }); if (!exists) { diff --git a/src/routes/events/[event_id]/(launcher)/launcher_session_view.svelte b/src/routes/events/[event_id]/(launcher)/launcher_session_view.svelte index 7b347b0e..e40788ed 100644 --- a/src/routes/events/[event_id]/(launcher)/launcher_session_view.svelte +++ b/src/routes/events/[event_id]/(launcher)/launcher_session_view.svelte @@ -1,13 +1,13 @@