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:
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { untrack } from 'svelte';
|
||||
let log_lvl: number = 2;
|
||||
|
||||
// *** Import Svelte specific
|
||||
@@ -29,8 +30,10 @@
|
||||
let { data, children }: Props = $props();
|
||||
|
||||
$effect(() => {
|
||||
$ae_loc.url_origin = data.url.origin;
|
||||
$ae_loc.params = data.params;
|
||||
untrack(() => {
|
||||
$ae_loc.url_origin = data.url.origin;
|
||||
$ae_loc.params = data.params;
|
||||
});
|
||||
|
||||
if (log_lvl > 1) {
|
||||
console.log(`+layout.svelte data:`, data);
|
||||
@@ -39,111 +42,113 @@
|
||||
|
||||
$effect(() => {
|
||||
if (browser) {
|
||||
if (data.url.searchParams.get('uuid')) {
|
||||
$idaa_loc.novi_uuid = data.url.searchParams.get('uuid'); // data.params.uuid;
|
||||
}
|
||||
if (data.url.searchParams.get('email')) {
|
||||
$idaa_loc.novi_email = decodeURIComponent(data.url.searchParams.get('email'));
|
||||
} else {
|
||||
$idaa_loc.novi_email = null;
|
||||
}
|
||||
if (data.url.searchParams.get('full_name')) {
|
||||
$idaa_loc.novi_full_name = decodeURIComponent(data.url.searchParams.get('full_name'));
|
||||
} else {
|
||||
$idaa_loc.novi_full_name = null;
|
||||
}
|
||||
$idaa_loc.novi_admin_li = $ae_loc.site_cfg_json?.novi_admin_li ?? [];
|
||||
$idaa_loc.novi_trusted_li = $ae_loc.site_cfg_json?.novi_trusted_li ?? [];
|
||||
// console.log(`$idaa_loc.novi_uuid:`, $idaa_loc.novi_uuid);
|
||||
// console.log(`$idaa_loc.novi_admin_li:`, $idaa_loc.novi_admin_li);
|
||||
untrack(() => {
|
||||
if (data.url.searchParams.get('uuid')) {
|
||||
$idaa_loc.novi_uuid = data.url.searchParams.get('uuid'); // data.params.uuid;
|
||||
}
|
||||
if (data.url.searchParams.get('email')) {
|
||||
$idaa_loc.novi_email = decodeURIComponent(data.url.searchParams.get('email'));
|
||||
} else {
|
||||
$idaa_loc.novi_email = null;
|
||||
}
|
||||
if (data.url.searchParams.get('full_name')) {
|
||||
$idaa_loc.novi_full_name = decodeURIComponent(data.url.searchParams.get('full_name'));
|
||||
} else {
|
||||
$idaa_loc.novi_full_name = null;
|
||||
}
|
||||
$idaa_loc.novi_admin_li = $ae_loc.site_cfg_json?.novi_admin_li ?? [];
|
||||
$idaa_loc.novi_trusted_li = $ae_loc.site_cfg_json?.novi_trusted_li ?? [];
|
||||
// console.log(`$idaa_loc.novi_uuid:`, $idaa_loc.novi_uuid);
|
||||
// console.log(`$idaa_loc.novi_admin_li:`, $idaa_loc.novi_admin_li);
|
||||
|
||||
// Reminder: super > manager > administrator > trusted > public > authenticated > anonymous
|
||||
// Reminder: super > manager > administrator > trusted > public > authenticated > anonymous
|
||||
|
||||
// NOTE: This is checking if they are in an iframe *and* have a Novi UUID. We ignore the iframe mode for trusted and above (administrators, managers, etc).
|
||||
if (
|
||||
$ae_loc?.iframe &&
|
||||
$idaa_loc?.novi_uuid?.length == 36 &&
|
||||
$idaa_loc?.novi_email?.length > 3 &&
|
||||
$idaa_loc?.novi_full_name?.length > 0
|
||||
) {
|
||||
$ae_loc.access_type = 'authenticated';
|
||||
$ae_loc.super_access = false;
|
||||
$ae_loc.manager_access = false;
|
||||
$ae_loc.administrator_access = false;
|
||||
$ae_loc.trusted_access = false;
|
||||
$ae_loc.public_access = false;
|
||||
$ae_loc.authenticated_access = true;
|
||||
$ae_loc.anonymous_access = true;
|
||||
// NOTE: This is checking if they are in an iframe *and* have a Novi UUID. We ignore the iframe mode for trusted and above (administrators, managers, etc).
|
||||
if (
|
||||
$ae_loc?.iframe &&
|
||||
$idaa_loc?.novi_uuid?.length == 36 &&
|
||||
$idaa_loc?.novi_email?.length > 3 &&
|
||||
$idaa_loc?.novi_full_name?.length > 0
|
||||
) {
|
||||
$ae_loc.access_type = 'authenticated';
|
||||
$ae_loc.super_access = false;
|
||||
$ae_loc.manager_access = false;
|
||||
$ae_loc.administrator_access = false;
|
||||
$ae_loc.trusted_access = false;
|
||||
$ae_loc.public_access = false;
|
||||
$ae_loc.authenticated_access = true;
|
||||
$ae_loc.anonymous_access = true;
|
||||
|
||||
// Resetting these just in case...
|
||||
$idaa_loc.bb.qry__hidden == 'not_hidden';
|
||||
$idaa_loc.bb.qry__enabled == 'enabled';
|
||||
// NOTE: This is sort of temporary while we work on getting Jisti working with IDAA's Novi site.
|
||||
} else if (
|
||||
$ae_loc?.iframe &&
|
||||
$idaa_loc?.novi_uuid?.length == 36
|
||||
) {
|
||||
$ae_loc.access_type = 'authenticated';
|
||||
$ae_loc.super_access = false;
|
||||
$ae_loc.manager_access = false;
|
||||
$ae_loc.administrator_access = false;
|
||||
$ae_loc.trusted_access = false;
|
||||
$ae_loc.public_access = false;
|
||||
$ae_loc.authenticated_access = true;
|
||||
$ae_loc.anonymous_access = true;
|
||||
// Resetting these just in case...
|
||||
$idaa_loc.bb.qry__hidden == 'not_hidden';
|
||||
$idaa_loc.bb.qry__enabled == 'enabled';
|
||||
// NOTE: This is sort of temporary while we work on getting Jisti working with IDAA's Novi site.
|
||||
} else if (
|
||||
$ae_loc?.iframe &&
|
||||
$idaa_loc?.novi_uuid?.length == 36
|
||||
) {
|
||||
$ae_loc.access_type = 'authenticated';
|
||||
$ae_loc.super_access = false;
|
||||
$ae_loc.manager_access = false;
|
||||
$ae_loc.administrator_access = false;
|
||||
$ae_loc.trusted_access = false;
|
||||
$ae_loc.public_access = false;
|
||||
$ae_loc.authenticated_access = true;
|
||||
$ae_loc.anonymous_access = true;
|
||||
|
||||
// Resetting these just in case...
|
||||
$idaa_loc.bb.qry__hidden == 'not_hidden';
|
||||
$idaa_loc.bb.qry__enabled == 'enabled';
|
||||
} else if ($ae_loc?.iframe) {
|
||||
$ae_loc.access_type = 'anonymous';
|
||||
$ae_loc.super_access = false;
|
||||
$ae_loc.manager_access = false;
|
||||
$ae_loc.administrator_access = false;
|
||||
$ae_loc.trusted_access = false;
|
||||
$ae_loc.public_access = false;
|
||||
$ae_loc.authenticated_access = false;
|
||||
$ae_loc.anonymous_access = true;
|
||||
// Resetting these just in case...
|
||||
$idaa_loc.bb.qry__hidden == 'not_hidden';
|
||||
$idaa_loc.bb.qry__enabled == 'enabled';
|
||||
} else if ($ae_loc?.iframe) {
|
||||
$ae_loc.access_type = 'anonymous';
|
||||
$ae_loc.super_access = false;
|
||||
$ae_loc.manager_access = false;
|
||||
$ae_loc.administrator_access = false;
|
||||
$ae_loc.trusted_access = false;
|
||||
$ae_loc.public_access = false;
|
||||
$ae_loc.authenticated_access = false;
|
||||
$ae_loc.anonymous_access = true;
|
||||
|
||||
// Resetting these just in case...
|
||||
$idaa_loc.bb.qry__hidden == 'not_hidden';
|
||||
$idaa_loc.bb.qry__enabled == 'enabled';
|
||||
}
|
||||
|
||||
if ($idaa_loc.novi_uuid) {
|
||||
let flag = false;
|
||||
// NOTE: Check if the novi_uuid is in the novi_admin_li list
|
||||
if ($idaa_loc.novi_admin_li) {
|
||||
if ($idaa_loc.novi_admin_li.includes($idaa_loc.novi_uuid)) {
|
||||
$ae_loc.access_type = 'administrator';
|
||||
$ae_loc.super_access = false;
|
||||
$ae_loc.manager_access = false;
|
||||
$ae_loc.administrator_access = true;
|
||||
$ae_loc.trusted_access = true;
|
||||
$ae_loc.public_access = true;
|
||||
$ae_loc.authenticated_access = true;
|
||||
$ae_loc.anonymous_access = true;
|
||||
|
||||
flag = true;
|
||||
}
|
||||
// Resetting these just in case...
|
||||
$idaa_loc.bb.qry__hidden == 'not_hidden';
|
||||
$idaa_loc.bb.qry__enabled == 'enabled';
|
||||
}
|
||||
|
||||
// NOTE: Check if the novi_uuid is in the novi_trusted_li list
|
||||
if ($idaa_loc.novi_trusted_li) {
|
||||
if ($idaa_loc.novi_trusted_li.includes($idaa_loc.novi_uuid)) {
|
||||
$ae_loc.access_type = 'trusted';
|
||||
$ae_loc.super_access = false;
|
||||
$ae_loc.manager_access = false;
|
||||
$ae_loc.administrator_access = false;
|
||||
$ae_loc.trusted_access = true;
|
||||
$ae_loc.public_access = true;
|
||||
$ae_loc.authenticated_access = true;
|
||||
$ae_loc.anonymous_access = true;
|
||||
if ($idaa_loc.novi_uuid) {
|
||||
let flag = false;
|
||||
// NOTE: Check if the novi_uuid is in the novi_admin_li list
|
||||
if ($idaa_loc.novi_admin_li) {
|
||||
if ($idaa_loc.novi_admin_li.includes($idaa_loc.novi_uuid)) {
|
||||
$ae_loc.access_type = 'administrator';
|
||||
$ae_loc.super_access = false;
|
||||
$ae_loc.manager_access = false;
|
||||
$ae_loc.administrator_access = true;
|
||||
$ae_loc.trusted_access = true;
|
||||
$ae_loc.public_access = true;
|
||||
$ae_loc.authenticated_access = true;
|
||||
$ae_loc.anonymous_access = true;
|
||||
|
||||
flag = true;
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Check if the novi_uuid is in the novi_trusted_li list
|
||||
if ($idaa_loc.novi_trusted_li) {
|
||||
if ($idaa_loc.novi_trusted_li.includes($idaa_loc.novi_uuid)) {
|
||||
$ae_loc.access_type = 'trusted';
|
||||
$ae_loc.super_access = false;
|
||||
$ae_loc.manager_access = false;
|
||||
$ae_loc.administrator_access = false;
|
||||
$ae_loc.trusted_access = true;
|
||||
$ae_loc.public_access = true;
|
||||
$ae_loc.authenticated_access = true;
|
||||
$ae_loc.anonymous_access = true;
|
||||
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { untrack } from 'svelte';
|
||||
let log_lvl: number = 0;
|
||||
|
||||
// *** Import Svelte specific
|
||||
|
||||
// *** Import Aether specific variables and functions
|
||||
import {
|
||||
ae_snip,
|
||||
@@ -21,7 +24,9 @@
|
||||
|
||||
let { data, children }: Props = $props();
|
||||
|
||||
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]);
|
||||
|
||||
$effect(() => {
|
||||
if (log_lvl > 1) {
|
||||
@@ -38,7 +43,9 @@
|
||||
}
|
||||
|
||||
if (ae_acct) {
|
||||
$idaa_slct.archive_obj_li = ae_acct.slct.archive_obj_li;
|
||||
untrack(() => {
|
||||
$idaa_slct.archive_obj_li = ae_acct.slct.archive_obj_li;
|
||||
});
|
||||
}
|
||||
});
|
||||
// $idaa_slct.archive_id = ae_acct.slct.archive_id; // Not set here yet.
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
// let ae_triggers: key_val = {};
|
||||
|
||||
// *** Quickly pull out data from parent(s)
|
||||
let ae_acct = data[$slct.account_id];
|
||||
let ae_acct = data[data.account_id];
|
||||
if (log_lvl) {
|
||||
console.log(`ae_acct = `, ae_acct);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { untrack } from 'svelte';
|
||||
let log_lvl: number = $state(0);
|
||||
|
||||
// *** Import Svelte specific
|
||||
@@ -31,7 +32,9 @@
|
||||
|
||||
let { data, children }: Props = $props();
|
||||
|
||||
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]);
|
||||
|
||||
$effect(() => {
|
||||
if (log_lvl > 1) {
|
||||
@@ -48,7 +51,9 @@
|
||||
}
|
||||
|
||||
if (ae_acct) {
|
||||
$idaa_slct.post_obj_li = ae_acct.slct.post_obj_li;
|
||||
untrack(() => {
|
||||
$idaa_slct.post_obj_li = ae_acct.slct.post_obj_li;
|
||||
});
|
||||
}
|
||||
});
|
||||
// $idaa_slct.post_id = ae_acct.slct.post_id; // Not set here yet.
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
import Comp__post_obj_id_view from '.././ae_idaa_comp__post_obj_id_view.svelte';
|
||||
|
||||
// *** Quickly pull out data from parent(s)
|
||||
let ae_acct = data[$slct.account_id];
|
||||
let ae_acct = data[data.account_id];
|
||||
if (log_lvl) {
|
||||
console.log(`ae_acct = `, ae_acct);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { untrack } from 'svelte';
|
||||
let log_lvl: number = 0;
|
||||
|
||||
// *** Import Svelte specific
|
||||
@@ -31,19 +32,32 @@
|
||||
|
||||
let { data, children }: Props = $props();
|
||||
|
||||
if (log_lvl > 1) {
|
||||
console.log(`ae_idaa_recovery_meetings +layout.svelte`, data);
|
||||
}
|
||||
// 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]);
|
||||
|
||||
// *** Quickly pull out data from parent(s)
|
||||
$slct.account_id = data.account_id;
|
||||
$effect(() => {
|
||||
if (log_lvl > 1) {
|
||||
console.log(`ae_idaa_recovery_meetings +layout.svelte`, data);
|
||||
}
|
||||
|
||||
let ae_acct = data[$slct.account_id];
|
||||
if (log_lvl) {
|
||||
console.log(`ae_acct = `, ae_acct);
|
||||
}
|
||||
// *** Quickly pull out data from parent(s)
|
||||
untrack(() => {
|
||||
$slct.account_id = data.account_id;
|
||||
});
|
||||
});
|
||||
|
||||
$idaa_slct.event_obj_li = ae_acct.slct.event_obj_li;
|
||||
$effect(() => {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_acct = `, ae_acct);
|
||||
}
|
||||
|
||||
if (ae_acct) {
|
||||
untrack(() => {
|
||||
$idaa_slct.event_obj_li = ae_acct.slct.event_obj_li;
|
||||
});
|
||||
}
|
||||
});
|
||||
// $idaa_slct.event_id = ae_acct.slct.event_id; // Not set here yet.
|
||||
|
||||
// *** Set initial variables
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { untrack } from 'svelte';
|
||||
interface Props {
|
||||
/** @type {import('./$types').PageData} */
|
||||
data: any;
|
||||
@@ -10,7 +11,6 @@
|
||||
// *** Import Svelte specific
|
||||
import { page } from '$app/state';
|
||||
import { browser } from '$app/environment';
|
||||
import { untrack } from 'svelte';
|
||||
|
||||
// *** Import other supporting libraries
|
||||
import { db_events } from '$lib/ae_events/db_events';
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
import Help_tech from '$lib/app_components/e_app_help_tech.svelte';
|
||||
|
||||
// *** Quickly pull out data from parent(s)
|
||||
let ae_acct = data[$slct.account_id];
|
||||
let ae_acct = data[data.account_id];
|
||||
if (log_lvl) {
|
||||
console.log(`ae_acct = `, ae_acct);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user