fix: move IDAA recovery meeting page browser block into onMount

Two state_referenced_locally warnings on data prop in
recovery_meetings/[event_id]/+page.svelte: reading a $props()
rune synchronously in a top-level if (browser) block only captures
the initial value.

Move the postMessage block into onMount (browser-only by nature);
remove the now-redundant 'browser' import.
This commit is contained in:
Scott Idem
2026-03-11 15:23:59 -04:00
parent a878e4a05b
commit 5c09730991

View File

@@ -9,8 +9,7 @@
let log_lvl: number = 0; let log_lvl: number = 0;
// *** Import Svelte specific // *** Import Svelte specific
import { onDestroy, untrack } from 'svelte'; import { onMount, onDestroy, untrack } from 'svelte';
import { browser } from '$app/environment';
// *** Import other supporting libraries // *** Import other supporting libraries
// import { Modal } from 'flowbite-svelte'; // import { Modal } from 'flowbite-svelte';
@@ -91,13 +90,11 @@
}) })
); );
if (browser) { // NOTE: onMount runs in browser only, so no browser guard needed.
console.log('Browser environment detected.'); // Use data[data.account_id].slct.event_id (from the load function / URL params),
// NOT $idaa_slct.event_id (the store) — the store is set by a $effect and may not
// NOTE: Use data[data.account_id].slct.event_id (from the load function / URL params), // reflect the correct value yet at this point.
// NOT $idaa_slct.event_id (the store). The store is updated by a $effect that runs onMount(() => {
// after this synchronous block — reading it here would send the old/null value and
// fail to update the parent page URL.
let message = { event_id: data[data.account_id]?.slct?.event_id ?? null }; let message = { event_id: data[data.account_id]?.slct?.event_id ?? null };
window.parent.postMessage(message, '*'); window.parent.postMessage(message, '*');
@@ -107,7 +104,7 @@
); );
window.parent.postMessage({ scroll_to: 0 }, '*'); // This should be in pixels window.parent.postMessage({ scroll_to: 0 }, '*'); // This should be in pixels
} }
} });
onDestroy(() => { onDestroy(() => {
if (log_lvl) { if (log_lvl) {