Close toast on click

This commit is contained in:
2025-09-07 03:53:57 +02:00
parent 39f61eaa96
commit 31508e74da
2 changed files with 13 additions and 6 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ usePWAReload();
<template #top> <template #top>
<VaNavbar shadowed> <VaNavbar shadowed>
<template #center> <template #center>
<RouterLink to="/" class="text-2xl font-bold hover:underline">TramTracks</RouterLink> <RouterLink to="/" class="text-2xl font-bold hover:underline">TramTrack</RouterLink>
</template> </template>
<template #right> <template #right>
<VaButton to="/stats" icon="leaderboard" title="Statistiken" /> <VaButton to="/stats" icon="leaderboard" title="Statistiken" />
+12 -5
View File
@@ -3,7 +3,7 @@ import { useRegisterSW } from 'virtual:pwa-register/vue';
import { useToast } from 'vuestic-ui'; import { useToast } from 'vuestic-ui';
export function usePWAReload() { export function usePWAReload() {
const { init } = useToast(); const { init, close } = useToast();
const { updateServiceWorker } = useRegisterSW({ const { updateServiceWorker } = useRegisterSW({
immediate: true, immediate: true,
@@ -24,14 +24,21 @@ export function usePWAReload() {
color: 'success', color: 'success',
duration: 2000 duration: 2000
}), }),
onNeedRefresh: () => onNeedRefresh: () => {
init({ const toastId = init({
title: 'Update verfügbar', title: 'Update verfügbar',
message: 'Für diese WebApp ist ein Update verfügbar, bitte klicke hier zum Aktualisieren!', message: 'Für diese WebApp ist ein Update verfügbar, bitte klicke hier zum Aktualisieren!',
color: 'warning', color: 'warning',
duration: 0, duration: 0,
closeable: false, closeable: false,
onClick: updateServiceWorker onClick: async () => {
}) await updateServiceWorker();
if (toastId) {
close(toastId);
}
}
});
}
}); });
} }