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:
@@ -39,12 +39,16 @@
|
||||
import Event_page_menu from './event_page_menu.svelte';
|
||||
|
||||
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
|
||||
let ae_acct = $derived(data[$slct.account_id]);
|
||||
// NOTE: Derived from data.account_id (prop) instead of $slct.account_id (store)
|
||||
// to prevent circular dependency loops during hydration.
|
||||
let ae_acct = $derived(data[data.account_id]);
|
||||
let event_id = $derived(data.params.event_id);
|
||||
|
||||
$effect(() => {
|
||||
if (ae_acct) {
|
||||
$events_slct.event_id = ae_acct.slct.event_id;
|
||||
untrack(() => {
|
||||
$events_slct.event_id = ae_acct.slct.event_id;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -74,11 +78,15 @@
|
||||
|
||||
// JSON formatted configuration options for an event, and specifically for the presentation management module.
|
||||
$effect(() => {
|
||||
if ($lq__event_obj?.mod_pres_mgmt_json) {
|
||||
events_func.sync_config__event_pres_mgmt({
|
||||
pres_mgmt_cfg_remote: $lq__event_obj.mod_pres_mgmt_json,
|
||||
pres_mgmt_cfg_local: $events_loc.pres_mgmt,
|
||||
log_lvl: log_lvl
|
||||
const remote_cfg = $lq__event_obj?.mod_pres_mgmt_json;
|
||||
const local_cfg = $events_loc.pres_mgmt;
|
||||
if (remote_cfg && local_cfg) {
|
||||
untrack(() => {
|
||||
events_func.sync_config__event_pres_mgmt({
|
||||
pres_mgmt_cfg_remote: remote_cfg,
|
||||
pres_mgmt_cfg_local: local_cfg,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user