fix(events): refresh file list on mount to populate event_session_type_code in Dexie

The presenter detail page loads files with try_cache:false, which fetches
fresh data from the API but does NOT write it to Dexie (by design in the
SWR implementation). The file list's liveQuery then reads stale Dexie
records that lack event_session_type_code, causing the PDF→image convert
button condition to silently fail for presenter files in poster sessions.

Fix: trigger a try_cache:true background refresh on mount in the direct
wrapper so fresh API data (with event_session_type_code='poster') is
persisted to Dexie and the liveQuery re-renders with the correct field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-03-11 13:33:31 -04:00
parent b2fa1a59dc
commit de8b85bb05

View File

@@ -21,14 +21,16 @@
}: Props = $props();
import { liveQuery } from 'dexie';
import { onMount } from 'svelte';
import type { key_val } from '$lib/stores/ae_stores';
import { ae_api } from '$lib/stores/ae_stores';
// import { ae_util } from '$lib/ae_utils/ae_utils';
import Element_manage_event_file_li from '$lib/elements/element_manage_event_file_li.svelte';
// import { core_func } from '$lib/ae_core_functions';
// import { ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
import { db_events } from '$lib/ae_events/db_events';
import { events_func } from '$lib/ae_events_functions';
// import { events_loc, events_sess, events_slct, events_trigger } from '$lib/stores/ae_events_stores';
// export let show_convert_btn: null|boolean = null;
@@ -39,6 +41,24 @@
ae_tmp.show__direct_download = false;
// let ae_triggers: key_val = {};
// WHY: When a parent page loads with try_cache:false (e.g. presenter detail),
// the fresh API data (including event_session_type_code) is NOT written to Dexie.
// The liveQuery below then sees stale Dexie records missing that field, so
// the PDF→image convert button condition silently fails. Triggering a try_cache:true
// refresh on mount ensures fresh data is persisted and liveQuery reflects it.
onMount(() => {
if (link_to_id) {
events_func.load_ae_obj_li__event_file({
api_cfg: $ae_api,
for_obj_type: link_to_type,
for_obj_id: link_to_id,
enabled: 'all',
hidden: 'all',
try_cache: true
});
}
});
let dq__where_val: string = `for_type`;
let dq__where_eq_val = $derived(link_to_type);
let dq__where_for_id_eq_val = $derived(link_to_id);