fix: derive poster session type from Dexie chain for presenter-linked files

v_event_file joins event_session only via event_file.event_session_id.
Files with for_type='event_presenter' have event_session_id=NULL on the
file record itself, so event_session_type_code is structurally always NULL
from the API for these files — no amount of refreshing can fix it.

Instead of relying on the file's event_session_type_code, derive the session
type in element_manage_event_file_li_direct via the Dexie chain:
  presenter.event_presentation_id → presentation.event_session_id → session.type_code

Pass the result as context_session_type_code to element_manage_event_file_li,
which now checks EITHER the file's own event_session_type_code OR the context
prop against 'poster' to show the PDF→Image convert button.

Sessions are guaranteed in Dexie because the pres_mgmt layout loads
inc_session_li:true on every navigation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-03-11 14:06:33 -04:00
parent 4690548946
commit 477fc16f16
2 changed files with 32 additions and 28 deletions

View File

@@ -35,6 +35,11 @@
allow_basic?: boolean;
allow_moderator?: boolean;
display_mode?: string; // 'default', 'compact', 'minimal', 'launcher'
// WHY: event_file.event_session_type_code is NULL for presenter-linked files because
// v_event_file joins event_session only via event_file.event_session_id, which is NULL
// when for_type='event_presenter'. The wrapper derives the correct type from the
// presenter → presentation → session chain and passes it here as context.
context_session_type_code?: string | null;
}
let {
@@ -45,7 +50,8 @@
link_to_id,
allow_basic = false,
allow_moderator = false,
display_mode = 'default'
display_mode = 'default',
context_session_type_code = null
}: Props = $props();
// export let show_convert_btn: null|boolean = null;
@@ -239,7 +245,7 @@
/>
<!-- PDF → webp convert button: only for poster sessions in edit mode -->
{#if $ae_loc.edit_mode && event_file_obj?.extension === 'pdf' && event_file_obj?.event_session_type_code === 'poster'}
{#if $ae_loc.edit_mode && event_file_obj?.extension === 'pdf' && (event_file_obj?.event_session_type_code === 'poster' || context_session_type_code === 'poster')}
<div>
{#if !convert_status_kv[event_file_obj.event_file_id] || convert_status_kv[event_file_obj.event_file_id] === 'idle'}
<button
@@ -275,6 +281,10 @@
</button>
{/if}
</div>
{:else}
<!-- this is showing -->
test test test
<!-- this is showing -->
{/if}
{#if ae_tmp.show__direct_download}