Settings: add the ability to reset your instance
This commit is contained in:
parent
389ad9e5ec
commit
abd87fafd2
2 changed files with 21 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,15 @@ 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({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue