More work on making the loading process better

This commit is contained in:
Scott Idem
2025-05-01 18:59:37 -04:00
parent 9687fe0c90
commit c6d21fadc2
4 changed files with 151 additions and 85 deletions

View File

@@ -112,45 +112,58 @@ if (browser) {
<button
onclick={() => {
// Confirm before clearing
if (!confirm("Are you sure you want to clear IndexedDB databases and some caches? This will also reload the page.")) {
return;
if ($ae_loc.edit_mode) {
// Confirm before clearing
if (!confirm("Are you sure you want to clear IndexedDB databases, localStorage, and sessionStorage? This will also reload the page.")) {
return;
}
console.log("Clearing IndexedDB, localStorage, sessionStorage, and reloading the page...");
// Clear Indexed DB
indexedDB.deleteDatabase('ae_archives_db'); // Archives module
indexedDB.deleteDatabase('ae_core_db');
indexedDB.deleteDatabase('ae_events_db'); // Events module
indexedDB.deleteDatabase('ae_journals_db'); // Journals module
indexedDB.deleteDatabase('ae_posts_db'); // Posts module
indexedDB.deleteDatabase('ae_sponsorships_db'); // Sponsorships module
// Clear localStorage and sessionStorage
// Clearing the localStorage will force it to be re-created.
localStorage.clear();
sessionStorage.clear();
goto('/', {invalidateAll: true});
// window.location.reload(true);
} else {
// Confirm before clearing
if (!confirm("Are you sure you want to clear IndexedDB databases and some caches? This will also reload the page.")) {
return;
}
console.log("Clearing IndexedDB, localStorage, sessionStorage, and reloading the page...");
// Clear Indexed DB
indexedDB.deleteDatabase('ae_archives_db'); // Archives module
indexedDB.deleteDatabase('ae_core_db');
indexedDB.deleteDatabase('ae_events_db'); // Events module
indexedDB.deleteDatabase('ae_journals_db'); // Journals module
indexedDB.deleteDatabase('ae_posts_db'); // Posts module
indexedDB.deleteDatabase('ae_sponsorships_db'); // Sponsorships module
window.location.reload(true);
}
// Clear Indexed DB
indexedDB.deleteDatabase('ae_core_db');
indexedDB.deleteDatabase('ae_journals_db');
// This does not seem to work fast enough or something?
goto('/', {invalidateAll: true});
// goto('/', {invalidateAll: true});
// The page does usually seem to reload correctly?
window.location.reload(true); // true only works with Firefox
// window.location.reload(true); // true only works with Firefox
// alert('Local and Session Storage cleared and Indexed DBs deleted. You will probably want to refresh the page.');
}}
ondblclick={() => {
// Confirm before clearing
if (!confirm("Are you sure you want to clear all *local* app data and settings? This will also reload the page.")) {
return;
}
console.log("Clearing IndexedDB, localStorage, sessionStorage, and reloading the page...");
// Clear Indexed DB
indexedDB.deleteDatabase('ae_core_db');
indexedDB.deleteDatabase('ae_journals_db');
// Clear localStorage and sessionStorage
// Clearing the localStorage will force it to be re-created.
localStorage.clear();
sessionStorage.clear();
goto('/', {invalidateAll: true});
window.location.reload(true);
}}
class="btn btn-sm variant-ghost-surface hover:variant-filled-warning"
title="Clear App Data &amp; Settings - Reload: Clear the browser storage for this site"
title="Clear App Data &amp; Settings: Clear IndexedDB and reload. If in edit mode localStorage and sessionStorage will also be cleared."
>
<!-- <span class="fas fa-eraser mx-1"></span> -->
<!-- <span class="fas fa-sync mx-1"></span> -->