From bf94e0dee93f33567fc3ddb431bf04ecd8754fac Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Wed, 11 Mar 2026 14:35:24 -0400 Subject: [PATCH] fix: extend poster session type context to all file list wrapper contexts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit element_manage_event_file_li_all.svelte — also derives context_session_type_code via Dexie chain (event_presentation → session, or event_presenter → presentation → session) and passes it to element_manage_event_file_li. Fixes the button not showing when viewing a presenter's files from the session view. element_manage_event_file_li_direct.svelte — extends the Dexie chain to also handle event_session (direct lookup) and event_presentation, not just event_presenter. Both: correct API URL to /v3/hosted_file/ per backend agent's examples. Co-Authored-By: Claude Sonnet 4.6 --- .../element_manage_event_file_li.svelte | 2 +- .../element_manage_event_file_li_all.svelte | 26 ++++++++++++++++++ ...element_manage_event_file_li_direct.svelte | 27 ++++++++++++++----- .../events/ae_comp__event_file_obj_tbl.svelte | 2 +- 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/lib/elements/element_manage_event_file_li.svelte b/src/lib/elements/element_manage_event_file_li.svelte index 61c5d3b7..1de46087 100644 --- a/src/lib/elements/element_manage_event_file_li.svelte +++ b/src/lib/elements/element_manage_event_file_li.svelte @@ -98,7 +98,7 @@ || event_file_obj.event_presentation_id || event_file_obj.event_id; const filename_no_ext = (event_file_obj.filename ?? 'poster_image').replace(/\.pdf$/i, ''); - const url = `${$ae_api.base_url}/v3/action/hosted_file/${event_file_obj.hosted_file_id}/convert_file` + const url = `${$ae_api.base_url}/v3/hosted_file/${event_file_obj.hosted_file_id}/convert_file` + `?link_to_type=${encodeURIComponent(link_to_type_val)}` + `&link_to_id=${encodeURIComponent(link_to_id_val)}` + `&filename_no_ext=${encodeURIComponent(filename_no_ext)}` diff --git a/src/lib/elements/element_manage_event_file_li_all.svelte b/src/lib/elements/element_manage_event_file_li_all.svelte index fc527142..74c4f30b 100644 --- a/src/lib/elements/element_manage_event_file_li_all.svelte +++ b/src/lib/elements/element_manage_event_file_li_all.svelte @@ -38,6 +38,31 @@ ae_tmp.show__direct_download = false; // let ae_triggers: key_val = {}; + // WHY: v_event_file joins event_session only via event_file.event_session_id. + // For files linked to a presentation or presenter, event_session_id is NULL on + // the file record itself, so event_session_type_code is always NULL from the API. + // Derive the session type from Dexie: presentation → event_session_id → type_code, + // or presenter → event_presentation_id → event_session_id → type_code. + let lq__context_session_type_code = $derived( + liveQuery(async () => { + if (link_to_type === 'event_presentation' && link_to_id) { + const presentation = await db_events.presentation.get(link_to_id); + if (!presentation?.event_session_id) return null; + const session = await db_events.session.get(presentation.event_session_id); + return session?.type_code ?? null; + } + if (link_to_type === 'event_presenter' && link_to_id) { + const presenter = await db_events.presenter.get(link_to_id); + if (!presenter?.event_presentation_id) return null; + const presentation = await db_events.presentation.get(presenter.event_presentation_id); + if (!presentation?.event_session_id) return null; + const session = await db_events.session.get(presentation.event_session_id); + return session?.type_code ?? null; + } + return null; + }) + ); + let dq__where_val = $derived(`${link_to_type}_id`); let dq__where_eq_val = $derived(link_to_id); @@ -74,4 +99,5 @@ {allow_moderator} {container_class_li} {display_mode} + context_session_type_code={$lq__context_session_type_code ?? null} /> diff --git a/src/lib/elements/element_manage_event_file_li_direct.svelte b/src/lib/elements/element_manage_event_file_li_direct.svelte index a8c1068e..f0147ef1 100644 --- a/src/lib/elements/element_manage_event_file_li_direct.svelte +++ b/src/lib/elements/element_manage_event_file_li_direct.svelte @@ -49,13 +49,26 @@ // Sessions are guaranteed in Dexie because the pres_mgmt layout loads inc_session_li:true. let lq__context_session_type_code = $derived( liveQuery(async () => { - if (link_to_type !== 'event_presenter' || !link_to_id) return null; - const presenter = await db_events.presenter.get(link_to_id); - if (!presenter?.event_presentation_id) return null; - const presentation = await db_events.presentation.get(presenter.event_presentation_id); - if (!presentation?.event_session_id) return null; - const session = await db_events.session.get(presentation.event_session_id); - return session?.type_code ?? null; + if (!link_to_id) return null; + if (link_to_type === 'event_session') { + const session = await db_events.session.get(link_to_id); + return session?.type_code ?? null; + } + if (link_to_type === 'event_presentation') { + const presentation = await db_events.presentation.get(link_to_id); + if (!presentation?.event_session_id) return null; + const session = await db_events.session.get(presentation.event_session_id); + return session?.type_code ?? null; + } + if (link_to_type === 'event_presenter') { + const presenter = await db_events.presenter.get(link_to_id); + if (!presenter?.event_presentation_id) return null; + const presentation = await db_events.presentation.get(presenter.event_presentation_id); + if (!presentation?.event_session_id) return null; + const session = await db_events.session.get(presentation.event_session_id); + return session?.type_code ?? null; + } + return null; }) ); diff --git a/src/routes/events/ae_comp__event_file_obj_tbl.svelte b/src/routes/events/ae_comp__event_file_obj_tbl.svelte index dc19c7ba..6846fbf0 100644 --- a/src/routes/events/ae_comp__event_file_obj_tbl.svelte +++ b/src/routes/events/ae_comp__event_file_obj_tbl.svelte @@ -87,7 +87,7 @@ || event_file_obj.event_presentation_id || event_file_obj.event_id; const filename_no_ext = (event_file_obj.filename ?? 'poster_image').replace(/\.pdf$/i, ''); - const url = `${$ae_api.base_url}/v3/action/hosted_file/${event_file_obj.hosted_file_id}/convert_file` + const url = `${$ae_api.base_url}/v3/hosted_file/${event_file_obj.hosted_file_id}/convert_file` + `?link_to_type=${encodeURIComponent(link_to_type)}` + `&link_to_id=${encodeURIComponent(link_to_id)}` + `&filename_no_ext=${encodeURIComponent(filename_no_ext)}`