Settings: add the ability to reset your instance

This commit is contained in:
MotorTruck1221 2025-01-14 23:51:55 -07:00
parent 389ad9e5ec
commit abd87fafd2
No known key found for this signature in database
GPG key ID: 08F417E2B8B61EA4
2 changed files with 21 additions and 3 deletions

View file

@ -2,7 +2,6 @@
import { MARKETPLACE_ENABLED } from "astro:env/client";
import { Icon } from "astro-icon/components";
import { getLangFromUrl, useTranslations } from "../i18n/utils";
import { isMobileNavOpen } from "../store.js";
import HeaderButton from "./HeaderButton.astro";
import Logo from "./Logo.astro";
const lang = getLangFromUrl(Astro.url);

View file

@ -31,6 +31,14 @@ const t = useTranslations(lang);
}}
both={{enabled: false}}
/>
<SettingsCard
title="Reset instance"
description="Reset your instance if your having troubles or problems."
input={{ input: false }}
button={{ name: 'Reset', id: 'resetinstance' }}
select={{ select: false }}
both={{ enabled: false }}
/>
</SettingsSection>
</SettingsLayout>
<script>
@ -43,7 +51,8 @@ const t = useTranslations(lang);
const handler = async () => {
const els = Elements.select([
{ type: 'id', val: 'lang' },
{ type: 'id', val: 'setlang' }
{ type: 'id', val: 'setlang' },
{ type: 'id', val: 'resetinstance' }
]);
const lang = defaultStore.getVal(SettingsVals.i18n.lang);
const val = Elements.exists<HTMLSelectElement>(await els.next());
@ -53,6 +62,16 @@ const t = useTranslations(lang);
defaultStore.setVal(SettingsVals.i18n.lang, val.value);
navigate(`${window.location.origin}/${val.value}/settings/misc`);
});
const resetButton = Elements.exists<HTMLButtonElement>(await els.next());
Elements.attachEvent(resetButton, "click", async () => {
const t = await navigator.serviceWorker.getRegistrations();
t.map(async (reg) => {
await reg.unregister();
});
localStorage.clear();
window.location.href = "/";
});
}
new EventHandler({