fix(events): switch onMount→\$effect for file list Dexie refresh
onMount fired before the parent presenter liveQuery resolved, so link_to_id was undefined and the refresh was silently skipped. Using \$effect makes the background refresh re-run once link_to_id becomes available (after the presenter Dexie lookup completes), ensuring event_session_type_code is written to Dexie and the PDF→image convert button renders correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
}: Props = $props();
|
||||
|
||||
import { liveQuery } from 'dexie';
|
||||
import { onMount } from 'svelte';
|
||||
import { untrack } from 'svelte';
|
||||
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
import { ae_api } from '$lib/stores/ae_stores';
|
||||
@@ -44,19 +44,26 @@
|
||||
// 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) {
|
||||
// the PDF→image convert button condition silently fails.
|
||||
//
|
||||
// Using $effect (not onMount) because link_to_id arrives AFTER mount when the
|
||||
// parent presenter liveQuery resolves — onMount fires too early and misses it.
|
||||
// untrack() prevents the function body's internals from registering as deps.
|
||||
$effect(() => {
|
||||
if (!link_to_id) return;
|
||||
const _id = link_to_id;
|
||||
const _type = link_to_type;
|
||||
const _cfg = $ae_api;
|
||||
untrack(() => {
|
||||
events_func.load_ae_obj_li__event_file({
|
||||
api_cfg: $ae_api,
|
||||
for_obj_type: link_to_type,
|
||||
for_obj_id: link_to_id,
|
||||
api_cfg: _cfg,
|
||||
for_obj_type: _type,
|
||||
for_obj_id: _id,
|
||||
enabled: 'all',
|
||||
hidden: 'all',
|
||||
try_cache: true
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
let dq__where_val: string = `for_type`;
|
||||
|
||||
Reference in New Issue
Block a user