Trying to clean up the initial loading... Checking the local storage and indexes and site keys.
This commit is contained in:
@@ -97,70 +97,70 @@ $slct = {
|
|||||||
// IDB caches - Check if the last reload timestamp for $ae_loc.last_idb_reload is no more than 15 minutes ago.
|
// 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 default_idb_reload_time = 120 * 60 * 1000; // 15 minutes?
|
||||||
let trusted_idb_reload_time = 4 * 60 * 60 * 1000; // 4 hours or 120 minutes?
|
let trusted_idb_reload_time = 4 * 60 * 60 * 1000; // 4 hours or 120 minutes?
|
||||||
if (!$ae_loc.last_idb_reload) {
|
// if (!$ae_loc.last_idb_reload) {
|
||||||
console.log(`Last reload not found. Need to reset.`);
|
// console.log(`Last reload not found. Need to reset.`);
|
||||||
|
|
||||||
// $ae_loc.last_idb_reload = Date.now();
|
// // $ae_loc.last_idb_reload = Date.now();
|
||||||
if (browser) {
|
// if (browser) {
|
||||||
$ae_loc.last_idb_reload = Date.now();
|
// $ae_loc.last_idb_reload = Date.now();
|
||||||
|
|
||||||
// Clear Indexed DB as well
|
// // Clear Indexed DB as well
|
||||||
indexedDB.deleteDatabase('ae_archives_db');
|
// indexedDB.deleteDatabase('ae_archives_db');
|
||||||
indexedDB.deleteDatabase('ae_core_db');
|
// indexedDB.deleteDatabase('ae_core_db');
|
||||||
indexedDB.deleteDatabase('ae_events_db');
|
// indexedDB.deleteDatabase('ae_events_db');
|
||||||
indexedDB.deleteDatabase('ae_notes_db');
|
// indexedDB.deleteDatabase('ae_notes_db');
|
||||||
indexedDB.deleteDatabase('ae_posts_db');
|
// indexedDB.deleteDatabase('ae_posts_db');
|
||||||
|
|
||||||
// localStorage.removeItem('ae_loc');
|
// // localStorage.removeItem('ae_loc');
|
||||||
// localStorage.removeItem('events_loc');
|
// // localStorage.removeItem('events_loc');
|
||||||
|
|
||||||
// window.location.reload();
|
// // window.location.reload();
|
||||||
}
|
// }
|
||||||
|
|
||||||
} 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_idb_reload && $ae_loc.trusted_access && (Date.now() - $ae_loc.last_idb_reload) > trusted_idb_reload_time) {
|
||||||
console.log(`Last reload too old:`, $ae_loc.last_idb_reload);
|
// console.log(`Last reload too old:`, $ae_loc.last_idb_reload);
|
||||||
|
|
||||||
if (browser) {
|
// if (browser) {
|
||||||
$ae_loc.last_idb_reload = Date.now();
|
// $ae_loc.last_idb_reload = Date.now();
|
||||||
|
|
||||||
// Clear Indexed DB as well
|
// // Clear Indexed DB as well
|
||||||
indexedDB.deleteDatabase('ae_archives_db');
|
// indexedDB.deleteDatabase('ae_archives_db');
|
||||||
indexedDB.deleteDatabase('ae_core_db');
|
// indexedDB.deleteDatabase('ae_core_db');
|
||||||
indexedDB.deleteDatabase('ae_events_db');
|
// indexedDB.deleteDatabase('ae_events_db');
|
||||||
indexedDB.deleteDatabase('ae_notes_db');
|
// indexedDB.deleteDatabase('ae_notes_db');
|
||||||
indexedDB.deleteDatabase('ae_posts_db');
|
// indexedDB.deleteDatabase('ae_posts_db');
|
||||||
|
|
||||||
// localStorage.removeItem('ae_loc');
|
// // localStorage.removeItem('ae_loc');
|
||||||
// localStorage.removeItem('events_loc');
|
// // localStorage.removeItem('events_loc');
|
||||||
|
|
||||||
window.location.reload();
|
// 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_idb_reload && (Date.now() - $ae_loc.last_idb_reload) > default_idb_reload_time) {
|
||||||
console.log(`Last reload too old:`, $ae_loc.last_idb_reload);
|
// console.log(`Last reload too old:`, $ae_loc.last_idb_reload);
|
||||||
|
|
||||||
if (browser) {
|
// if (browser) {
|
||||||
$ae_loc.last_idb_reload = Date.now();
|
// $ae_loc.last_idb_reload = Date.now();
|
||||||
|
|
||||||
// Clear Indexed DB as well
|
// // Clear Indexed DB as well
|
||||||
indexedDB.deleteDatabase('ae_core_db');
|
// indexedDB.deleteDatabase('ae_core_db');
|
||||||
indexedDB.deleteDatabase('ae_events_db');
|
// indexedDB.deleteDatabase('ae_events_db');
|
||||||
|
|
||||||
// localStorage.removeItem('ae_loc');
|
// // localStorage.removeItem('ae_loc');
|
||||||
// localStorage.removeItem('events_loc');
|
// // localStorage.removeItem('events_loc');
|
||||||
|
|
||||||
window.location.reload();
|
// window.location.reload();
|
||||||
}
|
// }
|
||||||
} else if (browser) {
|
// } else if (browser) {
|
||||||
console.log(`Last reload is recent: ${$ae_loc.last_idb_reload}`);
|
// console.log(`Last reload is recent: ${$ae_loc.last_idb_reload}`);
|
||||||
// Clear Indexed DB as well
|
// // Clear Indexed DB as well
|
||||||
// indexedDB.deleteDatabase('ae_core_db');
|
// // indexedDB.deleteDatabase('ae_core_db');
|
||||||
// indexedDB.deleteDatabase('ae_events_db');
|
// // indexedDB.deleteDatabase('ae_events_db');
|
||||||
|
|
||||||
// localStorage.removeItem('ae_loc');
|
// // localStorage.removeItem('ae_loc');
|
||||||
// localStorage.removeItem('events_loc');
|
// // localStorage.removeItem('events_loc');
|
||||||
|
|
||||||
// window.location.reload();
|
// // window.location.reload();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// There should almost always be an event_id set.
|
// There should almost always be an event_id set.
|
||||||
if ($ae_loc?.site_cfg_json.slct__event_id) {
|
if ($ae_loc?.site_cfg_json.slct__event_id) {
|
||||||
@@ -189,11 +189,7 @@ if ($ae_loc.site_cfg_json.slct__sponsorship_cfg_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This needs to be re-worked ASAP! 2024-11-21
|
// Updated 2024-11-21
|
||||||
// Is most of this even needed? Just check every time. Why do we care if we checked recently or ever.
|
|
||||||
// Instead: Check if the access key is set and if it is the same as the site or domain access key.
|
|
||||||
// What happens if the access key is set and it is not the same as the site or domain access key? I guess the restriction was removed so it can be used without the key.
|
|
||||||
|
|
||||||
if ($ae_loc.site_access_key || $ae_loc.site_domain_access_key) {
|
if ($ae_loc.site_access_key || $ae_loc.site_domain_access_key) {
|
||||||
console.log(`We need to do a current check against the allow_access value.`);
|
console.log(`We need to do a current check against the allow_access value.`);
|
||||||
|
|
||||||
@@ -214,69 +210,79 @@ if ($ae_loc.site_access_key || $ae_loc.site_domain_access_key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if ($ae_loc.iframe) {
|
|
||||||
// $ae_loc.allow_access = true;
|
|
||||||
// } else {
|
|
||||||
|
|
||||||
// if ($ae_loc.allow_access && !$ae_loc.key_checked) {
|
|
||||||
// console.log(`PASS: The access key was checked earlier.`);
|
|
||||||
|
|
||||||
// // allow_access should equal true or the access key.
|
|
||||||
// if ($ae_loc.site_access_key || $ae_loc.site_domain_access_key) {
|
|
||||||
// console.log(`We need to do a current check against the allow_access value.`);
|
|
||||||
// if ($ae_loc.site_access_key == $ae_loc.allow_access || $ae_loc.site_domain_access_key == $ae_loc.allow_access) {
|
|
||||||
// console.log(`PASS: The access key was checked earlier and we just now checked the key.`);
|
|
||||||
// } else {
|
|
||||||
// console.log(`FAIL: The access key was checked earlier, but just now failed.`);
|
|
||||||
// if ($ae_loc.trusted_access) {
|
|
||||||
// console.log(`FAIL: The access key was checked earlier and failed, but we have trusted access.`);
|
|
||||||
// $ae_loc.allow_access = true;
|
|
||||||
// } else {
|
|
||||||
// $ae_loc.allow_access = false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// // This means this site and domain do not require an access key.
|
|
||||||
// // Do nothing to change the allow_access here at this time.
|
|
||||||
// }
|
|
||||||
// } else if ($ae_loc.allow_access && $ae_loc.key_checked) {
|
|
||||||
// console.log(`PASS: The access key was checked earlier and we just now checked the key.`);
|
|
||||||
// } else if (!$ae_loc.allow_access && $ae_loc.key_checked) {
|
|
||||||
// console.log(`FAIL: The access key was checked earlier and failed.`);
|
|
||||||
// if ($ae_loc.trusted_access) {
|
|
||||||
// console.log(`FAIL: The access key was checked earlier and failed, but we have trusted access.`);
|
|
||||||
// $ae_loc.allow_access = true;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// console.log(`FAIL: The access key was not checked earlier.`);
|
|
||||||
// // $ae_loc.key_checked = true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $: access_key = data.url.searchParams.get('key');
|
|
||||||
// console.log(`access_key = `, access_key);
|
|
||||||
|
|
||||||
if (browser) {
|
if (browser) {
|
||||||
// Waiting until the browser exists.
|
if (!$ae_loc.last_idb_reload) {
|
||||||
if ($ae_loc && $ae_sess && $ae_loc.ver_idb != $ae_sess.ver_idb) {
|
if (log_lvl) {
|
||||||
console.log('New version of the IDB available!!!');
|
console.log(`Last reload not found. Need to set!`);
|
||||||
console.log(`$ae_loc.ver_idb: ${$ae_loc.ver_idb} != $ae_sess.ver_idb: ${$ae_sess.ver_idb}`);
|
}
|
||||||
|
|
||||||
|
$ae_loc.last_idb_reload = Date.now();
|
||||||
|
|
||||||
// Clear Indexed DB as well
|
// Clear Indexed DB as well
|
||||||
|
indexedDB.deleteDatabase('ae_archives_db');
|
||||||
indexedDB.deleteDatabase('ae_core_db');
|
indexedDB.deleteDatabase('ae_core_db');
|
||||||
indexedDB.deleteDatabase('ae_events_db');
|
indexedDB.deleteDatabase('ae_events_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) {
|
||||||
|
if (log_lvl) {
|
||||||
|
console.log(`Last (trusted) reload too old: ${$ae_loc.last_idb_reload}`);
|
||||||
|
}
|
||||||
|
|
||||||
$ae_loc.ver_idb = $ae_sess.ver_idb;
|
$ae_loc.last_idb_reload = 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_notes_db');
|
||||||
|
indexedDB.deleteDatabase('ae_posts_db');
|
||||||
|
|
||||||
|
// localStorage.removeItem('ae_loc');
|
||||||
|
// localStorage.removeItem('events_loc');
|
||||||
|
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
} else if ($ae_loc.last_idb_reload && (Date.now() - $ae_loc.last_idb_reload) > default_idb_reload_time) {
|
||||||
|
if (log_lvl) {
|
||||||
|
console.log(`Last (default) reload too old: ${$ae_loc.last_idb_reload}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ae_loc.last_idb_reload = 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_notes_db');
|
||||||
|
indexedDB.deleteDatabase('ae_posts_db');
|
||||||
|
|
||||||
|
// localStorage.removeItem('ae_loc');
|
||||||
|
// localStorage.removeItem('events_loc');
|
||||||
|
|
||||||
|
window.location.reload();
|
||||||
|
} else {
|
||||||
|
if (log_lvl > 1) {
|
||||||
|
console.log(`Last reload is recent: ${$ae_loc.last_idb_reload}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Waiting until the browser exists.
|
||||||
|
// if ($ae_loc && $ae_sess && $ae_loc.ver_idb != $ae_sess.ver_idb) {
|
||||||
|
// console.log('New version of the IDB available!!!');
|
||||||
|
// console.log(`$ae_loc.ver_idb: ${$ae_loc.ver_idb} != $ae_sess.ver_idb: ${$ae_sess.ver_idb}`);
|
||||||
|
|
||||||
|
// // Clear Indexed DB as well
|
||||||
|
// indexedDB.deleteDatabase('ae_archives_db');
|
||||||
|
// indexedDB.deleteDatabase('ae_core_db');
|
||||||
|
// indexedDB.deleteDatabase('ae_events_db');
|
||||||
|
// indexedDB.deleteDatabase('ae_notes_db');
|
||||||
|
// indexedDB.deleteDatabase('ae_posts_db');
|
||||||
|
|
||||||
|
// $ae_loc.ver_idb = $ae_sess.ver_idb;
|
||||||
|
|
||||||
|
// window.location.reload();
|
||||||
|
// }
|
||||||
|
|
||||||
if ($ae_loc && $ae_sess && ($ae_loc.ver != $ae_sess.ver)) {
|
if ($ae_loc && $ae_sess && ($ae_loc.ver != $ae_sess.ver)) {
|
||||||
console.log('New version of the data store available!!!');
|
console.log('New version of the data store available!!!');
|
||||||
console.log(`$ae_loc.ver: ${$ae_loc.ver} != $ae_sess.ver: ${$ae_sess.ver}`);
|
console.log(`$ae_loc.ver: ${$ae_loc.ver} != $ae_sess.ver: ${$ae_sess.ver}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user