diff --git a/src/lib/ae_stores.ts b/src/lib/ae_stores.ts index 1cf023f6..48360461 100644 --- a/src/lib/ae_stores.ts +++ b/src/lib/ae_stores.ts @@ -54,6 +54,7 @@ let ver_idb = '2025-04-18_1100'; // Not used const ae_app_local_data_defaults: key_val = { last_page_reload: null, // last_idb_reload: null, + last_cache_refresh: null, ver: ver, // ver, // '2025-04-18_1100', ver_idb: ver_idb, // '2025-04-18_1100', name: 'Aether - App Hub (SvelteKit 2.x Svelte 4.x)', diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 8e2c2afe..a5f93fb1 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -75,6 +75,30 @@ if (log_lvl > 1) { console.log(`ae_root +layout.svelte data:`, data); } +// Get the current datetime +let early_check_current_datetime = new Date(); // Date.now() + +// Check if the iframe parameter is set to true +// let early_check_iframe = data.url.searchParams.get('iframe'); + + +// if ( +// browser +// && early_check_iframe == 'true' +// && ( +// !$ae_loc?.last_cache_refresh +// || ( +// $ae_loc?.last_cache_refresh +// && (Date.now() - $ae_loc?.last_cache_refresh) > 1 * 60 * 1000 +// ) +// ) +// ) { +// console.log(`TEST: Use iframe layout! last_cache_refresh:`, $ae_loc?.last_cache_refresh); + +// // localStorage.clear(); +// window.location.reload(); +// } + let trigger_clear_access: null|boolean = $state(null); // let account_id = localStorage.getItem('ae_account_id'); @@ -187,11 +211,11 @@ if (log_lvl > 1) { // } // localStorage caches - Check if the last refresh timestamp for $ae_loc.last_refresh is no more than 48 hours ago. -let default_refresh_time = 48 * 60 * 60 * 1000; // 48 hours or 2880 minutes? 48 * 60 * +let default_refresh_time = 4 * 60 * 60 * 1000; // 48 hours or 2880 minutes? 48 * 60 * let trusted_refresh_time = 168 * 60 * 60 * 1000; // 1 week or 10080 minutes? // IDB caches - Check if the last refresh timestamp for $ae_loc.last_cache_refresh is no more than 15 minutes ago. -let default_idb_refresh_time = 120 * 60 * 1000; // 15 minutes? +let default_idb_refresh_time = 2 * 60 * 60 * 1000; // 15 minutes? let trusted_idb_refresh_time = 4 * 60 * 60 * 1000; // 4 hours or 120 minutes? // There should almost always be an event_id set. @@ -361,9 +385,9 @@ if (browser) { // } if (!$ae_loc?.last_cache_refresh) { - if (log_lvl) { + // if (log_lvl) { console.log(`Last reload not found. Need to set!`); - } + // } $ae_loc.last_cache_refresh = Date.now(); @@ -374,6 +398,10 @@ if (browser) { indexedDB.deleteDatabase('ae_journals_db'); indexedDB.deleteDatabase('ae_notes_db'); indexedDB.deleteDatabase('ae_posts_db'); + + localStorage.clear(); + + window.location.reload(); } else if ($ae_loc?.last_cache_refresh && $ae_loc?.trusted_access && (Date.now() - $ae_loc?.last_cache_refresh) > trusted_refresh_time) { if (log_lvl) { console.log(`Last (trusted) reload too old: ${$ae_loc.last_cache_refresh}`); @@ -628,6 +656,8 @@ $effect(() => { localStorage.clear(); sessionStorage.clear(); + confirm('Local and Session Storage cleared. The page should now refresh on its own.'); + window.location.reload(); }} ondblclick={() => { @@ -642,7 +672,8 @@ $effect(() => { localStorage.clear(); sessionStorage.clear(); - alert('Local and Session Storage cleared. The page should now refresh on its own.'); + confirm('Local and Session Storage cleared. The page should now refresh on its own.'); + // window.location.reload({forceGet: true}); // window.location.reload(true); window.location.reload(); @@ -673,31 +704,41 @@ $effect(() => {