Things are working better with the version changes.
This commit is contained in:
@@ -118,6 +118,21 @@ if (log_lvl > 1) {
|
||||
// $ae_loc.app_cfg.show_element__menu = false;
|
||||
// }
|
||||
|
||||
// if (!$ae_loc?.ver_testing) {
|
||||
// console.log(`TEST: AE Stores - ver_testing missing:`, $ae_loc);
|
||||
// // ae_app_local_data_struct = {
|
||||
// // ...$ae_loc,
|
||||
// // ...ae_app_local_data_struct,
|
||||
// // };
|
||||
// // $ae_loc.ver_testing = true; // test
|
||||
// } else {
|
||||
// console.log(`TEST: AE Stores - ver_testing found`);
|
||||
// // $ae_loc.ver_testing = false; // test 2
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// // This should only be temporary. || !$ae_loc?.person || !$ae_loc?.user
|
||||
// if (!$ae_loc) {
|
||||
// console.log('No ae_loc. Reloading page...');
|
||||
@@ -171,9 +186,13 @@ if (log_lvl > 1) {
|
||||
// $ae_loc.app_cfg.show_element__menu = false;
|
||||
// }
|
||||
|
||||
// IDB caches - Check if the last reload timestamp for $ae_loc.last_idb_reload is no more than 15 minutes ago.
|
||||
let default_idb_reload_time = 120 * 60 * 1000; // 15 minutes?
|
||||
let trusted_idb_reload_time = 4 * 60 * 60 * 1000; // 4 hours or 120 minutes?
|
||||
// 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 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 trusted_idb_refresh_time = 4 * 60 * 60 * 1000; // 4 hours or 120 minutes?
|
||||
|
||||
// There should almost always be an event_id set.
|
||||
if ($ae_loc?.site_cfg_json?.slct__event_id) {
|
||||
@@ -248,22 +267,22 @@ if (browser) {
|
||||
console.log('No ae_loc. Reloading page...');
|
||||
// window.location.reload();
|
||||
} else if ($ae_loc && $ae_sess && ($ae_loc.ver != $ae_sess.ver)) {
|
||||
console.log('New version of the ae_loc (core local storage) available!!!');
|
||||
console.log('TEST: New version of the ae_loc (core local storage) available!!!');
|
||||
console.log(`$ae_loc.ver: ${$ae_loc.ver} != $ae_sess.ver: ${$ae_sess.ver}`);
|
||||
|
||||
// alert('New version available!!!');
|
||||
// WARNING: The page should still manually be reloaded.
|
||||
|
||||
// $ae_loc.ver = $ae_sess.ver;
|
||||
|
||||
// console.log('Clearing localStorage...');
|
||||
// $ae_loc = null;
|
||||
// $ae_loc = {};
|
||||
// localStorage.removeItem('ae_loc');
|
||||
// localStorage.removeItem('ae_idaa_loc');
|
||||
// localStorage.removeItem('ae_journals_loc');
|
||||
// localStorage.removeItem('ae_events_loc');
|
||||
localStorage.clear();
|
||||
|
||||
// WARNING: The page should still manually be reloaded.
|
||||
|
||||
// sessionStorage.removeItem('ae_sess');
|
||||
// sessionStorage.removeItem('events_sess');
|
||||
// console.log('Clearing sessionStorage...');
|
||||
@@ -273,6 +292,7 @@ if (browser) {
|
||||
// goto(data.route.id, {replaceState: true, invalidateAll: true});
|
||||
// } catch (e) {
|
||||
// console.log('Error going to root page:', e);
|
||||
// goto('/', {replaceState: true, invalidateAll: true});
|
||||
// }
|
||||
|
||||
// Go to root if not already there. Do this in case things have significantly changed, including routes. We need them to manually click the Reload and Clear Cache button.
|
||||
@@ -280,6 +300,8 @@ if (browser) {
|
||||
// if (data.route.id !== '/') {
|
||||
// goto('/', {replaceState: true, invalidateAll: true});
|
||||
// }
|
||||
|
||||
// WARNING: The page should still manually be reloaded.
|
||||
} else if (!$ae_loc?.app_cfg) {
|
||||
console.log('No ae_loc.app_cfg. Reloading page...?');
|
||||
|
||||
@@ -338,12 +360,12 @@ if (browser) {
|
||||
// location.reload();
|
||||
// }
|
||||
|
||||
if (!$ae_loc.last_idb_reload) {
|
||||
if (!$ae_loc?.last_cache_refresh) {
|
||||
if (log_lvl) {
|
||||
console.log(`Last reload not found. Need to set!`);
|
||||
}
|
||||
|
||||
$ae_loc.last_idb_reload = Date.now();
|
||||
$ae_loc.last_cache_refresh = Date.now();
|
||||
|
||||
// Clear Indexed DB as well
|
||||
indexedDB.deleteDatabase('ae_archives_db');
|
||||
@@ -352,12 +374,52 @@ if (browser) {
|
||||
indexedDB.deleteDatabase('ae_journals_db');
|
||||
indexedDB.deleteDatabase('ae_notes_db');
|
||||
indexedDB.deleteDatabase('ae_posts_db');
|
||||
} else if ($ae_loc.last_idb_reload && $ae_loc.trusted_access && (Date.now() - $ae_loc.last_idb_reload) > trusted_idb_reload_time) {
|
||||
} 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_idb_reload}`);
|
||||
console.log(`Last (trusted) reload too old: ${$ae_loc.last_cache_refresh}`);
|
||||
}
|
||||
|
||||
$ae_loc.last_idb_reload = Date.now();
|
||||
$ae_loc.last_cache_refresh = Date.now();
|
||||
|
||||
// Clear Indexed DB as well
|
||||
indexedDB.deleteDatabase('ae_archives_db');
|
||||
indexedDB.deleteDatabase('ae_core_db');
|
||||
indexedDB.deleteDatabase('ae_events_db');
|
||||
indexedDB.deleteDatabase('ae_journals_db');
|
||||
indexedDB.deleteDatabase('ae_notes_db');
|
||||
indexedDB.deleteDatabase('ae_posts_db');
|
||||
|
||||
// localStorage.removeItem('ae_loc');
|
||||
// localStorage.removeItem('events_loc');
|
||||
localStorage.clear();
|
||||
|
||||
window.location.reload();
|
||||
} else if ($ae_loc?.last_cache_refresh && (Date.now() - $ae_loc?.last_cache_refresh) > default_refresh_time) {
|
||||
// if (log_lvl) {
|
||||
console.log(`Last (default) reload too old: ${$ae_loc.last_cache_refresh}`);
|
||||
// }
|
||||
|
||||
$ae_loc.last_cache_refresh = Date.now();
|
||||
|
||||
// Clear Indexed DB as well
|
||||
indexedDB.deleteDatabase('ae_archives_db');
|
||||
indexedDB.deleteDatabase('ae_core_db');
|
||||
indexedDB.deleteDatabase('ae_events_db');
|
||||
indexedDB.deleteDatabase('ae_journals_db');
|
||||
indexedDB.deleteDatabase('ae_notes_db');
|
||||
indexedDB.deleteDatabase('ae_posts_db');
|
||||
|
||||
// localStorage.removeItem('ae_loc');
|
||||
// localStorage.removeItem('events_loc');
|
||||
localStorage.clear();
|
||||
|
||||
window.location.reload();
|
||||
} else if ($ae_loc?.last_cache_refresh && $ae_loc?.trusted_access && (Date.now() - $ae_loc?.last_cache_refresh) > trusted_idb_refresh_time) {
|
||||
if (log_lvl) {
|
||||
console.log(`Last (trusted) reload too old: ${$ae_loc.last_cache_refresh}`);
|
||||
}
|
||||
|
||||
$ae_loc.last_cache_refresh = Date.now();
|
||||
|
||||
// Clear Indexed DB as well
|
||||
indexedDB.deleteDatabase('ae_archives_db');
|
||||
@@ -371,12 +433,12 @@ if (browser) {
|
||||
// localStorage.removeItem('events_loc');
|
||||
|
||||
window.location.reload();
|
||||
} else if ($ae_loc.last_idb_reload && (Date.now() - $ae_loc.last_idb_reload) > default_idb_reload_time) {
|
||||
} else if ($ae_loc.last_cache_refresh && (Date.now() - $ae_loc.last_cache_refresh) > default_idb_refresh_time) {
|
||||
if (log_lvl) {
|
||||
console.log(`Last (default) reload too old: ${$ae_loc.last_idb_reload}`);
|
||||
console.log(`Last (default) reload too old: ${$ae_loc.last_cache_refresh}`);
|
||||
}
|
||||
|
||||
$ae_loc.last_idb_reload = Date.now();
|
||||
$ae_loc.last_cache_refresh = Date.now();
|
||||
|
||||
// Clear Indexed DB as well
|
||||
indexedDB.deleteDatabase('ae_archives_db');
|
||||
@@ -392,7 +454,7 @@ if (browser) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
if (log_lvl > 1) {
|
||||
console.log(`Last reload is recent: ${$ae_loc.last_idb_reload}`);
|
||||
console.log(`Last reload is recent: ${$ae_loc.last_cache_refresh}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user