Added a third check for managers. Because why not. Wrapping up for the day.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
/** @type {import('./$types').LayoutData} */
|
||||
// /** @type {import('./$types').LayoutProps} */
|
||||
|
||||
let log_lvl: number = 1;
|
||||
let log_lvl: number = 0;
|
||||
|
||||
// *** Import Svelte specific
|
||||
import { tick } from 'svelte';
|
||||
@@ -172,15 +172,20 @@ if ($ae_loc && $ae_sess && ($ae_loc.ver != $ae_sess.ver)) {
|
||||
|
||||
let default_refresh_minutes: number = 60;
|
||||
let trusted_refresh_minutes: number = 120;
|
||||
let manager_refresh_minutes: number = 2880;
|
||||
if ($ae_loc?.site_cfg_json?.default_refresh_minutes) {
|
||||
default_refresh_minutes = $ae_loc.site_cfg_json.default_refresh_minutes;
|
||||
}
|
||||
if ($ae_loc?.site_cfg_json?.trusted_refresh_minutes) {
|
||||
trusted_refresh_minutes = $ae_loc.site_cfg_json.trusted_refresh_minutes;
|
||||
}
|
||||
if ($ae_loc?.site_cfg_json?.manager_refresh_minutes) {
|
||||
manager_refresh_minutes = $ae_loc.site_cfg_json.manager_refresh_minutes;
|
||||
}
|
||||
|
||||
let default_refresh_time = default_refresh_minutes * 60 * 1000; // 48 hours or 2880 minutes? 48 * 60 *
|
||||
let trusted_refresh_time = trusted_refresh_minutes * 60 * 1000; // 1 week or 10080 minutes?
|
||||
let manager_refresh_time = manager_refresh_minutes * 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 * 60 * 1000; // 15 minutes?
|
||||
@@ -227,6 +232,17 @@ if (!$ae_loc?.last_cache_refresh) { // Default is null, currently...
|
||||
flag_reload = true;
|
||||
flag_expired = true;
|
||||
|
||||
$ae_loc.cache_expired = true;
|
||||
$ae_loc.allow_access = false;
|
||||
} else if ($ae_loc?.manager_access && (Date.now() - $ae_loc?.last_cache_refresh) > manager_refresh_time) {
|
||||
console.log(`ROOT: Last (manager) local config reload too old for all caches: ${$ae_loc.last_cache_refresh}`);
|
||||
|
||||
flag_clear_idb = true;
|
||||
flag_clear_local = true;
|
||||
flag_clear_sess = true;
|
||||
flag_reload = true;
|
||||
flag_expired = true;
|
||||
|
||||
$ae_loc.cache_expired = true;
|
||||
$ae_loc.allow_access = false;
|
||||
} else {
|
||||
@@ -616,8 +632,29 @@ $effect(() => {
|
||||
// location.reload();
|
||||
|
||||
clearInterval(interval);
|
||||
} else if ($ae_loc?.manager_access && (Date.now() - $ae_loc?.last_cache_refresh) > manager_refresh_time) {
|
||||
if (log_lvl) {
|
||||
console.log(`ROOT LOOP: Last (manager) local config reload too old for all caches: ${$ae_loc.last_cache_refresh}`);
|
||||
}
|
||||
|
||||
// flag_clear_idb = true;
|
||||
// flag_clear_local = true;
|
||||
// flag_clear_sess = true;
|
||||
// flag_reload = true;
|
||||
// flag_expired = true;
|
||||
|
||||
$ae_loc.allow_access = false;
|
||||
$ae_loc.cache_expired = true;
|
||||
|
||||
// location.reload();
|
||||
|
||||
clearInterval(interval);
|
||||
} else {
|
||||
if (log_lvl > 1) {
|
||||
console.log(`ROOT LOOP: Last local config reload is recent: ${$ae_loc.last_cache_refresh}`);
|
||||
}
|
||||
}
|
||||
}, 7000);
|
||||
}, 45000);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user