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