diff --git a/src/routes/idaa/(idaa)/recovery_meetings/ae_idaa_comp__event_obj_id_edit_v2.svelte b/src/routes/idaa/(idaa)/recovery_meetings/ae_idaa_comp__event_obj_id_edit_v2.svelte index ddcb9911..69e2ebc7 100644 --- a/src/routes/idaa/(idaa)/recovery_meetings/ae_idaa_comp__event_obj_id_edit_v2.svelte +++ b/src/routes/idaa/(idaa)/recovery_meetings/ae_idaa_comp__event_obj_id_edit_v2.svelte @@ -12,6 +12,7 @@ }: Props = $props(); // *** Import Svelte specific + import { onMount } from 'svelte'; import { fade } from 'svelte/transition'; import { browser } from '$app/environment'; import { goto } from '$app/navigation'; @@ -192,21 +193,6 @@ ? JSON.parse(localStorage.getItem('lu_country_list') ?? '') : [] ); - if (lu_country_list && lu_country_list.length > 50 && Math.random() < 0.8) { - console.log(`Already have country list! ${lu_country_list.length}`); - } else { - core_func - .load_ae_obj_li__country({ api_cfg: $ae_api, log_lvl: log_lvl }) - .then(function (result) { - if (result) { - lu_country_list = result; - localStorage.setItem('lu_country_list', JSON.stringify(result)); - } - }) - .catch(function (error: any) { - console.log('No results returned or failed.', error); - }); - } // Load country subdivision lookup list (states/provinces, cached in localStorage) let lu_country_subdivision_list = $state( @@ -214,30 +200,51 @@ ? JSON.parse(localStorage.getItem('lu_country_subdivision_list') ?? '') : [] ); - if ( - lu_country_subdivision_list && - lu_country_subdivision_list.length > 50 && - Math.random() < 0.8 - ) { - console.log( - `Already have country subdivision list! ${lu_country_subdivision_list.length}` - ); - } else { - core_func - .load_ae_obj_li__country_subdivision({ api_cfg: $ae_api, log_lvl: log_lvl }) - .then(function (result) { - if (result) { - lu_country_subdivision_list = result; - localStorage.setItem( - 'lu_country_subdivision_list', - JSON.stringify(result) - ); - } - }) - .catch(function (error: any) { - console.log('No results returned or failed.', error); - }); - } + + onMount(() => { + // These reads of $state runes must be inside a closure (onMount) to avoid + // Svelte's state_referenced_locally warning — the values are valid at mount. + if (lu_country_list && lu_country_list.length > 50 && Math.random() < 0.8) { + console.log(`Already have country list! ${lu_country_list.length}`); + } else { + core_func + .load_ae_obj_li__country({ api_cfg: $ae_api, log_lvl: log_lvl }) + .then(function (result) { + if (result) { + lu_country_list = result; + localStorage.setItem('lu_country_list', JSON.stringify(result)); + } + }) + .catch(function (error: any) { + console.log('No results returned or failed.', error); + }); + } + + if ( + lu_country_subdivision_list && + lu_country_subdivision_list.length > 50 && + Math.random() < 0.8 + ) { + console.log( + `Already have country subdivision list! ${lu_country_subdivision_list.length}` + ); + } else { + core_func + .load_ae_obj_li__country_subdivision({ api_cfg: $ae_api, log_lvl: log_lvl }) + .then(function (result) { + if (result) { + lu_country_subdivision_list = result; + localStorage.setItem( + 'lu_country_subdivision_list', + JSON.stringify(result) + ); + } + }) + .catch(function (error: any) { + console.log('No results returned or failed.', error); + }); + } + }); $effect(() => { if ($idaa_slct.event_obj) { @@ -1965,10 +1972,6 @@ Copy and paste link: ${ @apply select p-1 preset-tonal-surface hover:preset-filled-surface-100-900; } - .field-richtext { - @apply preset-tonal-surface hover:preset-filled-surface-100-900; - } - .field-hint { @apply block text-xs font-normal text-surface-500 -mt-0.5; }