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,
|
||||
LifeBuoy,
|
||||
RefreshCw,
|
||||
SquareX
|
||||
SquareX,
|
||||
Trash2
|
||||
} from '@lucide/svelte';
|
||||
// *** Import Aether specific variables and functions
|
||||
import {
|
||||
@@ -454,67 +455,30 @@ class:to-90%={$ae_sess.show_help_tech} -->
|
||||
">
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
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;
|
||||
}
|
||||
onclick={async () => {
|
||||
const edit_mode = $ae_loc.edit_mode;
|
||||
const confirm_msg = edit_mode
|
||||
? 'Clear all IDB caches, localStorage, and sessionStorage? Your sign-in will be preserved. This will reload the page.'
|
||||
: 'Clear all IDB caches? This will reload the page.';
|
||||
|
||||
console.log(
|
||||
'Clearing IndexedDB, localStorage, sessionStorage, and reloading the page...'
|
||||
);
|
||||
if (!confirm(confirm_msg)) return;
|
||||
|
||||
// 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();
|
||||
|
||||
// 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();
|
||||
// Enumerate and delete every IDB database on this origin.
|
||||
const db_list = await indexedDB.databases();
|
||||
console.log('[clear_reload] IDB databases found:', db_list.map((d) => d.name));
|
||||
for (const db of db_list) {
|
||||
if (db.name) indexedDB.deleteDatabase(db.name);
|
||||
}
|
||||
|
||||
// This does not seem to work fast enough or something?
|
||||
// goto('/', {invalidateAll: true});
|
||||
if (edit_mode) {
|
||||
// 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(true); // true only works with Firefox
|
||||
// alert('Local and Session Storage cleared and Indexed DBs deleted. You will probably want to refresh the page.');
|
||||
window.location.reload();
|
||||
}}
|
||||
class="
|
||||
btn btn-sm
|
||||
@@ -524,13 +488,49 @@ class:to-90%={$ae_sess.show_help_tech} -->
|
||||
transition-all
|
||||
{btn_class}
|
||||
"
|
||||
title="Clear App Data & 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> -->
|
||||
title="Clear & Reload: Delete all IDB caches and reload. In edit mode also clears localStorage/sessionStorage, preserving your sign-in.">
|
||||
<RefreshCw size="1em" class="inline-block" />
|
||||
<span class="md:inline">Clear & Reload</span>
|
||||
</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 -->
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user