Fix infinite hydration loop and stabilize global store synchronization

- Refactored layouts to derive account data from stable props instead of reactive stores.
- Wrapped store updates in untrack() with deep equality guards to prevent infinite re-renders.
- Resolved duplicate untrack declarations and missing imports across the project.
- Added fetch safeguards to Element_data_store to prevent redundant API calls.
- Standardized hydration patterns to break circular dependencies during initial load.
This commit is contained in:
Scott Idem
2026-02-08 17:15:20 -05:00
parent 88bc18cf15
commit 718de1457d
33 changed files with 455 additions and 1567 deletions

View File

@@ -3,6 +3,7 @@
let log_lvl: number = $state(0);
// *** Import Svelte specific
import { untrack } from 'svelte';
// import { browser } from '$app/environment';
import { goto, invalidateAll } from '$app/navigation';
@@ -36,23 +37,27 @@
let { data, children }: Props = $props();
$events_loc.qry__enabled = 'enabled';
$events_loc.qry__hidden = 'not_hidden';
$events_loc.qry__limit = 15;
$events_loc.qry__offset = 0;
// Use effects for store initializations to prevent render-phase updates
$effect(() => {
untrack(() => {
$events_loc.qry__enabled = 'enabled';
$events_loc.qry__hidden = 'not_hidden';
$events_loc.qry__limit = 15;
$events_loc.qry__offset = 0;
});
});
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
// $slct.account_id = data.account_id;
console.log(`$slct.account_id = `, $slct.account_id);
if (log_lvl) {
console.log(`$slct.account_id = `, $slct.account_id);
}
let ae_acct = data[$slct.account_id];
// console.log(`ae_acct = `, ae_acct);
let ae_acct = $derived(data[data.account_id]);
$events_slct.event_id = ae_acct.slct.event_id;
// $events_slct.event_obj = ae_acct.slct.event_obj;
$events_slct.event_obj_li = ae_acct.slct.event_obj_li;
$effect(() => {
if (ae_acct) {
untrack(() => {
$events_slct.event_id = ae_acct.slct.event_id;
$events_slct.event_obj_li = ae_acct.slct.event_obj_li;
});
}
});
let ae_promises: key_val = {};