refactor(storage): replace hardcoded IDB lists with indexedDB.databases() in all clear buttons

Consistent with the tech help panel update — all Clear Storage / Clear & Reload
buttons now enumerate IDB databases dynamically so new modules are included
automatically without needing to update these lists.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-05-14 18:23:29 -04:00
parent c4e2e64a7e
commit 48a748d314
3 changed files with 48 additions and 34 deletions

View File

@@ -217,26 +217,26 @@ function handle_clear_storage(item: null | string) {
</button>
<button
class="btn btn-sm preset-tonal-warning"
title="Clear the browser storage for this page"
onclick={() => {
title="Full Reset: Delete ALL IndexedDB databases, clear localStorage and sessionStorage for this origin, then reload."
onclick={async () => {
if (
!confirm(
'Are you sure you want to clear the local and session storage?'
'FULL RESET: Delete ALL IndexedDB databases, clear localStorage and sessionStorage, then reload? This cannot be undone.'
)
) {
return false;
return;
}
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);
}
// Clear the local and session storage
localStorage.clear();
sessionStorage.clear();
// Clear Indexed DB as well
indexedDB.deleteDatabase('ae_core_db');
indexedDB.deleteDatabase('ae_events_db');
window.location.reload();
// alert('Local and Session Storage cleared and Indexed DBs deleted. You will probably want to refresh the page.');
}}>
<Eraser size="1em" class="mx-1" />
Clear Storage & DB

View File

@@ -80,22 +80,21 @@ function toggle_theme_mode() {
// DOM sync (class) is handled reactively in +layout.svelte effect #3
}
// ── Dev: clear all browser storage + key IndexedDB tables, then reload ──
function handle_clear_storage_db() {
// ── Dev: clear all browser storage + all IndexedDB databases, then reload ──
async function handle_clear_storage_db() {
if (
!confirm(
'Clear all local/session storage and IndexedDB? The page will reload.'
'FULL RESET: Delete ALL IndexedDB databases, clear localStorage and sessionStorage, then reload? This cannot be undone.'
)
)
return;
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();
indexedDB.deleteDatabase('ae_archives_db');
indexedDB.deleteDatabase('ae_core_db');
indexedDB.deleteDatabase('ae_events_db');
indexedDB.deleteDatabase('ae_journals_db');
indexedDB.deleteDatabase('ae_posts_db');
indexedDB.deleteDatabase('ae_sponsorships_db');
window.location.reload();
}