Added new clear IDB tables button to the AE system bar/menu.

This commit is contained in:
Scott Idem
2026-06-18 15:27:03 -04:00
parent 6222f7655d
commit fa7889bd80

View File

@@ -15,7 +15,10 @@
import {
Bug,
CircleX,
// DatabaseMinus,
// DatabaseX,
Eraser,
ListX,
Lock,
// LockKeyhole,
LogOut,
@@ -80,8 +83,24 @@ function toggle_theme_mode() {
// DOM sync (class) is handled reactively in +layout.svelte effect #3
}
// ── Dev: clear IDB only — preserves localStorage/sessionStorage (auth state, prefs) ──
async function handle_clear_idb_only() {
if (
!confirm(
'Clear all IndexedDB databases then reload? localStorage and sessionStorage will be preserved.'
)
)
return;
const db_list = await indexedDB.databases();
console.log('[clear_idb] IDB databases found:', db_list.map((d) => d.name));
for (const db of db_list) {
if (db.name) indexedDB.deleteDatabase(db.name);
}
window.location.reload();
}
// ── Dev: clear all browser storage + all IndexedDB databases, then reload ──
async function handle_clear_storage_db() {
async function handle_clear_storage_and_idb() {
if (
!confirm(
'FULL RESET: Delete ALL IndexedDB databases, clear localStorage and sessionStorage, then reload? This cannot be undone.'
@@ -289,6 +308,22 @@ function apply_theme(value: string) {
<span class="italic opacity-50">Not signed in</span>
{/if}
</div>
<!-- Button to fully clear *only* the IDB tables. This is mostly to clear up orphan records, but sometimes the table itself needs a reset. -->
<!-- Clear IDB only — *preserves* localStorage/sessionStorage -->
<button
type="button"
class="btn btn-sm preset-filled-warning-200-800 hover:preset-filled-error-100-900 group/menu transition-all duration-200"
onclick={handle_clear_idb_only}
title="Clear cached records in the local IndexedDB tables. You will not be signed out. This is safe. This preserves localStorage/sessionStorage.">
<!-- <Eraser size="1.1em" /> -->
<!-- <DatabaseX size="1.1em" /> -->
<ListX size="1.1em" />
<span
class="btn-label max-w-0 opacity-0 transition-all duration-800 hover:duration-100 group-hover/menu:max-w-24 group-hover/menu:opacity-100"
>Clear IDB</span>
</button>
<button
type="button"
class="btn btn-icon btn-sm preset-filled-tertiary-200-800 hover:preset-filled-error ml-2 shrink-0 transition-all"
@@ -513,14 +548,14 @@ function apply_theme(value: string) {
Reload Page
</button>
<!-- Clear storage + IndexedDB -->
<!-- Clear localStorage, sessionStorage, and all IndexedDB databases — full reset -->
<button
type="button"
class="btn btn-sm preset-tonal-error w-full justify-end"
onclick={handle_clear_storage_db}
title="Clear localStorage, sessionStorage, and all IndexedDB tables then reload">
onclick={handle_clear_storage_and_idb}
title="Clear all IndexedDB tables only then reload">
<Eraser size="1em" class="opacity-60" />
Clear Storage & DB
Clear All Storage + IDB
</button>
<!-- URL param builder -->