More work on page load and cache checking
This commit is contained in:
@@ -215,8 +215,8 @@ let trusted_refresh_time = trusted_refresh_minutes * 60 * 1000;
|
|||||||
let manager_refresh_time = manager_refresh_minutes * 60 * 1000;
|
let manager_refresh_time = manager_refresh_minutes * 60 * 1000;
|
||||||
|
|
||||||
// IDB caches - Check if the last refresh timestamp for $ae_loc.last_cache_refresh is no more than 15 minutes ago.
|
// 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 * 60 * 1000; // 15 minutes?
|
let default_idb_refresh_time = 4 * 60 * 60 * 1000; // 15 minutes?
|
||||||
let trusted_idb_refresh_time = 240 * 60 * 60 * 1000; // 4 hours or 120 minutes?
|
let trusted_idb_refresh_time = 8 * 60 * 60 * 1000; // 4 hours or 120 minutes? 8 hours or 480 minutes?
|
||||||
|
|
||||||
if (!$ae_loc?.last_cache_refresh) { // Default is null, currently...
|
if (!$ae_loc?.last_cache_refresh) { // Default is null, currently...
|
||||||
console.log(`ROOT: Last reload not found. Need to set!`);
|
console.log(`ROOT: Last reload not found. Need to set!`);
|
||||||
@@ -302,22 +302,22 @@ if (!$ae_loc?.last_cache_refresh) { // Default is null, currently...
|
|||||||
flag_clear_idb = true;
|
flag_clear_idb = true;
|
||||||
// flag_clear_local = false;
|
// flag_clear_local = false;
|
||||||
// flag_clear_sess = false;
|
// flag_clear_sess = false;
|
||||||
flag_reload = true;
|
// flag_reload = true;
|
||||||
flag_expired = true;
|
// flag_expired = true;
|
||||||
|
|
||||||
$ae_loc.cache_expired = true;
|
// $ae_loc.cache_expired = true;
|
||||||
$ae_loc.allow_access = false;
|
// $ae_loc.allow_access = false;
|
||||||
} else if (!$ae_loc?.trusted_access && (Date.now() - $ae_loc.last_cache_refresh) > default_idb_refresh_time) {
|
} else if (!$ae_loc?.trusted_access && (Date.now() - $ae_loc.last_cache_refresh) > default_idb_refresh_time) {
|
||||||
console.log(`ROOT: Last (default) IDB reload too old for IDB: ${$ae_loc.last_cache_refresh}`);
|
console.log(`ROOT: Last (default) IDB reload too old for IDB: ${$ae_loc.last_cache_refresh}`);
|
||||||
|
|
||||||
flag_clear_idb = true;
|
flag_clear_idb = true;
|
||||||
// flag_clear_local = false;
|
// flag_clear_local = false;
|
||||||
// flag_clear_sess = false;
|
// flag_clear_sess = false;
|
||||||
flag_reload = true;
|
// flag_reload = true;
|
||||||
flag_expired = true;
|
// flag_expired = true;
|
||||||
|
|
||||||
$ae_loc.cache_expired = true;
|
// $ae_loc.cache_expired = true;
|
||||||
$ae_loc.allow_access = false;
|
// $ae_loc.allow_access = false;
|
||||||
} else {
|
} else {
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log(`ROOT: Last IDB reload is recent: ${$ae_loc.last_cache_refresh}`);
|
console.log(`ROOT: Last IDB reload is recent: ${$ae_loc.last_cache_refresh}`);
|
||||||
@@ -329,6 +329,22 @@ if (!$ae_loc?.last_cache_refresh) { // Default is null, currently...
|
|||||||
}
|
}
|
||||||
// END: Expired Cache Check:
|
// END: Expired Cache Check:
|
||||||
|
|
||||||
|
// $effect(() => {
|
||||||
|
if (browser && flag_clear_idb) {
|
||||||
|
if (log_lvl) {
|
||||||
|
console.log(`ROOT: Clear IDB...`);
|
||||||
|
}
|
||||||
|
flag_clear_idb = false;
|
||||||
|
$ae_loc.last_cache_refresh = Date.now();
|
||||||
|
|
||||||
|
clear_idb();
|
||||||
|
|
||||||
|
if (log_lvl) {
|
||||||
|
console.log(`ROOT: IDB cleared. Reload!`);
|
||||||
|
}
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// BEGIN: Access Checks:
|
// BEGIN: Access Checks:
|
||||||
// Updated 2024-11-21
|
// Updated 2024-11-21
|
||||||
@@ -371,50 +387,12 @@ if ($ae_loc?.site_cfg_json?.theme_mode) {
|
|||||||
$ae_loc.theme_mode = $ae_loc.site_cfg_json.theme_mode;
|
$ae_loc.theme_mode = $ae_loc.site_cfg_json.theme_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// BEGIN: iframe Check:
|
|
||||||
|
|
||||||
// END: iframe Check:
|
// BEGIN: Special Checks for Events, Sponsorships, IDAA, CHOW, LCI, etc.:
|
||||||
|
|
||||||
|
|
||||||
// BEGIN: Special Checks for Events, Sponsorships, IDAA, CHOW, etc.:
|
|
||||||
// There should almost always be an event_id set.
|
|
||||||
// if ($ae_loc?.site_cfg_json?.slct__event_id) {
|
|
||||||
// $events_slct.event_id = $ae_loc.site_cfg_json.slct__event_id;
|
|
||||||
// $events_loc.event_id = $ae_loc.site_cfg_json.slct__event_id;
|
|
||||||
// } else if ($events_slct?.event_id) {
|
|
||||||
// // console.log(`Event ID already set:`, $events_slct.event_id);
|
|
||||||
// $events_loc.event_id = $events_slct.event_id;
|
|
||||||
// } else {
|
|
||||||
// if (log_lvl > 1) {
|
|
||||||
// console.log(`No Event ID set!`);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // This is mainly for Precon CHOW
|
|
||||||
// if ($ae_loc?.site_cfg_json?.slct__sponsorship_cfg_id) {
|
|
||||||
// $slct.sponsorship_cfg_id = $ae_loc.site_cfg_json.slct__sponsorship_cfg_id;
|
|
||||||
// if ($ae_loc?.mod?.sponsorships) {
|
|
||||||
// $ae_loc.mod.sponsorships.cfg_id = $ae_loc.site_cfg_json.slct__sponsorship_cfg_id;
|
|
||||||
// } else {
|
|
||||||
// $ae_loc.mod = {
|
|
||||||
// ...$ae_loc.mod,
|
|
||||||
// sponsorships: {
|
|
||||||
// cfg_id: $ae_loc.site_cfg_json.slct__sponsorship_cfg_id
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// } else if ($ae_loc?.sponsorship_cfg_id) {
|
|
||||||
// $slct.sponsorship_cfg_id = $ae_loc.sponsorship_cfg_id;
|
|
||||||
// $ae_loc.mod.sponsorships.cfg_id = $ae_loc.sponsorship_cfg_id;
|
|
||||||
// } else {
|
|
||||||
// if (log_lvl > 1) {
|
|
||||||
// console.log(`No Sponsorship Config ID set.`);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // END: Special Checks
|
// // END: Special Checks
|
||||||
|
|
||||||
// Root Svelte Layout Specific:
|
// Root Svelte Layout Specific:
|
||||||
let trigger_clear_access: null|boolean = $state(null);
|
// let trigger_clear_access: null|boolean = $state(null);
|
||||||
|
|
||||||
if (browser) {
|
if (browser) {
|
||||||
document.documentElement.setAttribute('data-theme', $ae_loc?.theme_name ?? 'nouveau');
|
document.documentElement.setAttribute('data-theme', $ae_loc?.theme_name ?? 'nouveau');
|
||||||
@@ -427,14 +405,14 @@ if (browser && flag_reload) {
|
|||||||
console.log(`ROOT: Reloading page after other flags checked...`);
|
console.log(`ROOT: Reloading page after other flags checked...`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear Indexed DB as well
|
// // Clear Indexed DB as well
|
||||||
if (flag_clear_idb) {
|
// if (flag_clear_idb) {
|
||||||
if (log_lvl) {
|
// if (log_lvl) {
|
||||||
console.log(`ROOT: Clearing IndexedDB databases...`);
|
// console.log(`ROOT: Clearing IndexedDB databases...`);
|
||||||
}
|
// }
|
||||||
|
|
||||||
clear_idb();
|
// clear_idb();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Clear localStorage and sessionStorage
|
// Clear localStorage and sessionStorage
|
||||||
if (flag_clear_local) {
|
if (flag_clear_local) {
|
||||||
@@ -629,7 +607,7 @@ $effect(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (browser) {
|
if (browser) {
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
@@ -831,21 +809,6 @@ $effect(() => {
|
|||||||
if (!confirm('Are you sure you want to clear the local and session storage?')) {
|
if (!confirm('Are you sure you want to clear the local and session storage?')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Clear the local and session storage
|
|
||||||
// localStorage.clear();
|
|
||||||
// sessionStorage.clear();
|
|
||||||
|
|
||||||
// // Clear Indexed DB as well
|
|
||||||
// indexedDB.deleteDatabase('ae_core_db');
|
|
||||||
// indexedDB.deleteDatabase('ae_archives_db');
|
|
||||||
// indexedDB.deleteDatabase('ae_events_db');
|
|
||||||
// indexedDB.deleteDatabase('ae_posts_db');
|
|
||||||
|
|
||||||
// window.location.reload();
|
|
||||||
// // alert('Local and Session Storage cleared and Indexed DBs deleted. You will probably want to refresh the page.');
|
|
||||||
|
|
||||||
console.log('Reloading page...');
|
|
||||||
// Clear the IndexedDB
|
// Clear the IndexedDB
|
||||||
clear_idb();
|
clear_idb();
|
||||||
|
|
||||||
@@ -975,7 +938,13 @@ email = ${$ae_loc?.email}
|
|||||||
onclick={() => {
|
onclick={() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}}
|
}}
|
||||||
class="btn btn-sm m-1 preset-tonal-surface border border-surface-500 hover:preset-tonal-warning border border-warning-500 hover:variant-outline-warning text-warning-800 hover:text-warning-900 transition-all"
|
class="
|
||||||
|
btn btn-sm m-1
|
||||||
|
preset-tonal-surface border-surface-500
|
||||||
|
hover:preset-tonal-warning hover:border-warning-500 hover:preset-outlined-warning
|
||||||
|
text-warning-800 hover:text-warning-900
|
||||||
|
transition-all
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<!-- <span class="fas fa-sync mx-1"></span> -->
|
<!-- <span class="fas fa-sync mx-1"></span> -->
|
||||||
<RefreshCw class="mx-1" />
|
<RefreshCw class="mx-1" />
|
||||||
|
|||||||
Reference in New Issue
Block a user