From 5c09730991ab944b538c5ac6441c7138cadfadb7 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Wed, 11 Mar 2026 15:23:59 -0400 Subject: [PATCH] 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. --- .../recovery_meetings/[event_id]/+page.svelte | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) 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) {