refactor: migrate Full Reset buttons to core_func.clear_all_storage()

+page.svelte and e_app_help_tech.svelte both had inline Full Reset implementations
(SW unregister + Cache + IDB + localStorage + sessionStorage). Replaced with
core_func.clear_all_storage() for consistency with the sys bar and fix-sw page.

Also fixes a title mismatch in e_app_help_tech Full Reset: title omitted SW
unregistration even though the code was doing it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-06-24 14:21:10 -04:00
parent 9b471f6639
commit db382b796c
2 changed files with 5 additions and 34 deletions

View File

@@ -54,6 +54,7 @@ import {
type key_val
} from '$lib/stores/ae_stores';
import { api } from '$lib/ae_api/api';
import { core_func } from '$lib/ae_core/ae_core_functions';
if (log_lvl) {
console.log(`Help - technical support component loaded`);
@@ -514,23 +515,7 @@ class:to-90%={$ae_sess.show_help_tech} -->
return;
}
if ('serviceWorker' in navigator) {
const registrations = await navigator.serviceWorker.getRegistrations();
for (const reg of registrations) await reg.unregister();
}
const cache_keys = await caches.keys();
for (const key of cache_keys) await caches.delete(key);
// 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();
await core_func.clear_all_storage();
window.location.reload();
}}
class="
@@ -541,7 +526,7 @@ class:to-90%={$ae_sess.show_help_tech} -->
transition-all
{btn_class}
"
title="Full Reset: Enumerate and delete ALL IndexedDB databases for this origin, clear localStorage and sessionStorage, then reload.">
title="Full Reset: Unregister service workers, clear SW Cache Storage, delete all IndexedDB databases, clear localStorage and sessionStorage, then reload.">
<Trash2 size="1em" class="inline-block" />
<span class="md:inline">Full Reset</span>
</button>

View File

@@ -29,6 +29,7 @@ import {
slct,
slct_trigger
} from '$lib/stores/ae_stores';
import { core_func } from '$lib/ae_core/ae_core_functions';
interface Props {
/** @type {import('./$types').PageData} */
data: any;
@@ -139,22 +140,7 @@ onMount(() => {
// Unregister service workers and clear Cache Storage so stale
// SW-cached assets don't survive the reset and re-serve old bundles.
if ('serviceWorker' in navigator) {
const registrations = await navigator.serviceWorker.getRegistrations();
for (const reg of registrations) await reg.unregister();
}
const cache_keys = await caches.keys();
for (const key of cache_keys) await caches.delete(key);
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();
await core_func.clear_all_storage();
window.location.reload();
}}
class="btn btn-sm