feat(help): improve Clear & Reload + add Full Reset button in tech help panel
Reworks Clear & Reload to use indexedDB.databases() (dynamic enumeration) instead of a hardcoded DB list. Edit mode clears localStorage/sessionStorage while preserving ae_loc (sign-in + permissions). Normal mode clears IDB only. Adds new Full Reset button — wipes all IDB, localStorage, and sessionStorage for the origin with no preservation. Useful for diagnosing quota/storage issues. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -42,7 +42,8 @@ import {
|
|||||||
ChevronRight,
|
ChevronRight,
|
||||||
LifeBuoy,
|
LifeBuoy,
|
||||||
RefreshCw,
|
RefreshCw,
|
||||||
SquareX
|
SquareX,
|
||||||
|
Trash2
|
||||||
} from '@lucide/svelte';
|
} from '@lucide/svelte';
|
||||||
// *** Import Aether specific variables and functions
|
// *** Import Aether specific variables and functions
|
||||||
import {
|
import {
|
||||||
@@ -454,67 +455,30 @@ class:to-90%={$ae_sess.show_help_tech} -->
|
|||||||
">
|
">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onclick={() => {
|
onclick={async () => {
|
||||||
if ($ae_loc.edit_mode) {
|
const edit_mode = $ae_loc.edit_mode;
|
||||||
// Confirm before clearing
|
const confirm_msg = edit_mode
|
||||||
if (
|
? 'Clear all IDB caches, localStorage, and sessionStorage? Your sign-in will be preserved. This will reload the page.'
|
||||||
!confirm(
|
: 'Clear all IDB caches? This will reload the page.';
|
||||||
'Are you sure you want to clear IndexedDB databases, localStorage, and sessionStorage? This will also reload the page.'
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(
|
if (!confirm(confirm_msg)) return;
|
||||||
'Clearing IndexedDB, localStorage, sessionStorage, and reloading the page...'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Clear Indexed DB
|
// Enumerate and delete every IDB database on this origin.
|
||||||
indexedDB.deleteDatabase('ae_archives_db'); // Archives module
|
const db_list = await indexedDB.databases();
|
||||||
indexedDB.deleteDatabase('ae_core_db');
|
console.log('[clear_reload] IDB databases found:', db_list.map((d) => d.name));
|
||||||
indexedDB.deleteDatabase('ae_events_db'); // Events module
|
for (const db of db_list) {
|
||||||
indexedDB.deleteDatabase('ae_journals_db'); // Journals module
|
if (db.name) indexedDB.deleteDatabase(db.name);
|
||||||
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();
|
|
||||||
|
|
||||||
// Reload the current iframe URL so Novi/query params stay intact.
|
|
||||||
window.location.reload();
|
|
||||||
} 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This does not seem to work fast enough or something?
|
if (edit_mode) {
|
||||||
// goto('/', {invalidateAll: true});
|
// Preserve ae_loc (sign-in credentials + permissions) across the wipe.
|
||||||
|
const ae_loc_saved = localStorage.getItem('ae_loc');
|
||||||
|
localStorage.clear();
|
||||||
|
sessionStorage.clear();
|
||||||
|
if (ae_loc_saved) localStorage.setItem('ae_loc', ae_loc_saved);
|
||||||
|
}
|
||||||
|
|
||||||
// The page does usually seem to reload correctly?
|
window.location.reload();
|
||||||
// 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.');
|
|
||||||
}}
|
}}
|
||||||
class="
|
class="
|
||||||
btn btn-sm
|
btn btn-sm
|
||||||
@@ -524,13 +488,49 @@ class:to-90%={$ae_sess.show_help_tech} -->
|
|||||||
transition-all
|
transition-all
|
||||||
{btn_class}
|
{btn_class}
|
||||||
"
|
"
|
||||||
title="Clear App Data & Settings: Clear IndexedDB and reload. If in edit mode localStorage and sessionStorage will also be cleared.">
|
title="Clear & Reload: Delete all IDB caches and reload. In edit mode also clears localStorage/sessionStorage, preserving your sign-in.">
|
||||||
<!-- <span class="fas fa-eraser mx-1"></span> -->
|
|
||||||
<!-- <span class="fas fa-sync mx-1"></span> -->
|
|
||||||
<RefreshCw size="1em" class="inline-block" />
|
<RefreshCw size="1em" class="inline-block" />
|
||||||
<span class="md:inline">Clear & Reload</span>
|
<span class="md:inline">Clear & Reload</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<!-- Nuclear clear: enumerates all IDB databases dynamically + always clears localStorage/sessionStorage.
|
||||||
|
Useful when the hardcoded list above is stale or when diagnosing quota/storage bugs. -->
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onclick={async () => {
|
||||||
|
if (
|
||||||
|
!confirm(
|
||||||
|
'FULL RESET: Delete ALL IndexedDB databases, clear localStorage and sessionStorage, then reload? This cannot be undone.'
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enumerate every IDB database on this origin and delete them all.
|
||||||
|
const db_list = await indexedDB.databases();
|
||||||
|
console.log('[clear_all] IDB databases found:', db_list.map((d) => d.name));
|
||||||
|
for (const db of db_list) {
|
||||||
|
if (db.name) indexedDB.deleteDatabase(db.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
localStorage.clear();
|
||||||
|
sessionStorage.clear();
|
||||||
|
|
||||||
|
window.location.reload();
|
||||||
|
}}
|
||||||
|
class="
|
||||||
|
btn btn-sm
|
||||||
|
preset-tonal-surface
|
||||||
|
preset-outlined-error-100-900
|
||||||
|
hover:preset-filled-error-200-800
|
||||||
|
transition-all
|
||||||
|
{btn_class}
|
||||||
|
"
|
||||||
|
title="Full Reset: Enumerate and delete ALL IndexedDB databases for this origin, clear localStorage and sessionStorage, then reload.">
|
||||||
|
<Trash2 size="1em" class="inline-block" />
|
||||||
|
<span class="md:inline">Full Reset</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
<!-- Cancel button -->
|
<!-- Cancel button -->
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
Reference in New Issue
Block a user