Finally getting the initial loading better

This commit is contained in:
Scott Idem
2024-03-26 17:12:35 -04:00
parent 4d486a580c
commit f20c6ef706
10 changed files with 139 additions and 128 deletions

View File

@@ -1,7 +1,7 @@
<script lang="ts">
/** @type {import('./$types').LayoutData} */
export let data: any;
// console.log(`ae_ Svelte root +layout data:`, data);
console.log(`ae_ Svelte root +layout data:`, data);
import { onMount } from 'svelte';
import '../app.postcss';
@@ -54,7 +54,7 @@ import { api } from '$lib/api';
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
import { events_loc, events_slct } from '$lib/ae_events_stores';
import type { key_val } from '$lib/ae_stores';
// console.log($ae_loc, $ae_sess, $ae_api);
console.log($ae_loc, $ae_sess, $ae_api);
import Element_access_type from '$lib/element_access_type.svelte';
import Element_app_cfg from '$lib/element_app_cfg.svelte';
@@ -78,16 +78,53 @@ if ($ae_loc.site_cfg_json.slct__event_id) {
}
// We want to loop through all of the data store (ds) key value pairs and set them to localStorage
if (data.ae_ds) {
for (let [key, value] of Object.entries(data.ae_ds)) {
// $: if (data.ae_ds) {
// console.log(`ae_ds__ data:`, data.ae_ds)
// for (let [key, value] of Object.entries(data.ae_ds)) {
// console.log(`ae_ds__ key: ${key}, value:`, value);
// localStorageStore(`ae_ds__${key}`, value);
// }
// }
import { browser } from '$app/environment';
// async function save_ds_to_local (ae_ds: any) {
// console.log(`ae_ds__ data:`, ae_ds)
// for (let [key, value] of Object.entries(ae_ds)) {
// console.log(`ae_ds__ key: ${key}, value:`, value);
// localStorage.setItem(`ae_ds__${key}`, JSON.stringify(value));
// }
// }
if (browser) {
// Waiting until the browser exists.
// save_ds_to_local(data.ae_ds);
let ae_ds = data.ae_ds;
console.log(`ae_ds__ data:`, ae_ds)
for (let [key, value] of Object.entries(ae_ds)) {
console.log(`ae_ds__ key: ${key}, value:`, value);
localStorageStore(`ae_ds__${key}`, value);
localStorage.setItem(`ae_ds__${key}`, JSON.stringify(value));
}
}
onMount(() => {
// console.log('Root: +layout.svelte');
console.log('Root: +layout.svelte');
// Waiting until the browser exists.
// save_ds_to_local(data.ae_ds);
// console.log(`ae_ds_testing = `, $ds_testing);
// $ds_testing = {'test': 'Changed by Scott'};
// if (data.ae_ds) {
// console.log(`ae_ds__ data:`, data.ae_ds)
// for (let [key, value] of Object.entries(data.ae_ds)) {
// console.log(`ae_ds__ key: ${key}, value:`, value);
// localStorageStore(`ae_ds__${key}`, value);
// }
// }
let iframe = data.url.searchParams.get('iframe');
if (iframe == 'true') {