IDAA: guard attend_json.zoom against SWR IDB re-fire crash

The Zoom button onclick initialises attend_json.zoom. However the
background SWR list fetch (load_ae_obj_li__event in +layout.ts) can
overwrite $idaa_slct.event_obj with a fresh IDB record where
attend_json = {} (no zoom key), even if the Zoom button was already
clicked.

Without the guard, the $effect that rebuilds the Zoom full URL and the
template bindings below the Zoom fields access attend_json.zoom.passcode_enc
on an undefined object, throwing a TypeError and crashing the component.

Fix: add `&& $idaa_slct.event_obj.attend_json?.zoom` guard to both the
$effect condition and the {#if} block that renders the Zoom input fields.
This commit is contained in:
Scott Idem
2026-03-10 14:22:23 -04:00
parent 3f57077a8b
commit 44d4b8e04f

View File

@@ -643,13 +643,19 @@ Copy and paste link: <a href="${link_base_url}?event_id=${event_do.event_id}">${
}
}
// Rebuild the Zoom full URL whenever Meeting ID, Passcode, Encrypted Passcode, or Domain changes
// Rebuild the Zoom full URL whenever Meeting ID, Passcode, Encrypted Passcode, or Domain changes.
// IMPORTANT: Guard attend_json.zoom before accessing its sub-properties.
// Background SWR re-fires (load_ae_obj_li__event in +layout.ts) can overwrite
// $idaa_slct.event_obj with a fresh IDB record where attend_json = {} (no zoom key),
// even if the Zoom button was already clicked. Without the guard, the access to
// attend_json.zoom.passcode_enc below throws a TypeError and crashes the component.
$effect(() => {
if (
$idaa_trig == 'update_zoom_full_url' &&
$idaa_slct.event_obj.attend_url_code &&
$idaa_slct.event_obj.attend_url_passcode &&
$idaa_sess.recovery_meetings.attend_platform === 'Zoom'
$idaa_sess.recovery_meetings.attend_platform === 'Zoom' &&
$idaa_slct.event_obj.attend_json?.zoom // guard: zoom may be undefined after IDB re-fire
) {
$idaa_trig = null;
@@ -1106,8 +1112,12 @@ Copy and paste link: <a href="${link_base_url}?event_id=${event_do.event_id}">${
</div>
</div>
<!-- Zoom fields -->
{#if $idaa_sess.recovery_meetings.attend_platform === 'Zoom'}
<!-- Zoom fields.
Guard attend_json.zoom: the Zoom button onclick initializes it, but a background
SWR IDB re-fire (load_ae_obj_li__event from +layout.ts) can reset attend_json
to {} afterward, leaving attend_json.zoom undefined. The bind:value bindings
below crash with a TypeError if zoom is undefined — the guard prevents that. -->
{#if $idaa_sess.recovery_meetings.attend_platform === 'Zoom' && $idaa_slct.event_obj.attend_json?.zoom}
<div class="platform-fields flex flex-row flex-wrap gap-3">
<label class="field-label" for="attend_url_code">
Zoom Meeting ID <span class="field-required">*</span>