call refreshApp() and reload the page on refreshApp event without displaying popup message

This commit is contained in:
summersamara 2023-04-04 17:50:27 +02:00 committed by 778a69cd
parent 6b2d6783bc
commit 44f32494b8

View file

@ -129,31 +129,20 @@ export default class App extends Vue {
console.debug("online"); console.debug("online");
}); });
document.addEventListener("refreshApp", (event: Event) => { document.addEventListener("refreshApp", (event: Event) => {
this.$buefy.snackbar.open({ const refreshAppEvent = async () => {
queue: false, // eslint-disable-next-line @typescript-eslint/ban-ts-comment
indefinite: true, // @ts-ignore
type: "is-secondary", const detail = event.detail;
actionText: this.$t("Update app") as string, const registration = detail as ServiceWorkerRegistration;
cancelText: this.$t("Ignore") as string, try {
message: this.$t("A new version is available.") as string, await this.refreshApp(registration);
onAction: async () => { window.location.reload();
// eslint-disable-next-line @typescript-eslint/ban-ts-comment } catch (err) {
// @ts-ignore console.error(err);
const detail = event.detail; }
const registration = detail as ServiceWorkerRegistration; };
try {
await this.refreshApp(registration); refreshAppEvent();
window.location.reload();
} catch (err) {
console.error(err);
this.$notifier.error(
this.$t(
"An error has occured while refreshing the page."
) as string
);
}
},
});
}); });
this.interval = setInterval(async () => { this.interval = setInterval(async () => {