Warn when offline

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-05-12 18:10:33 +02:00
parent d19de15c11
commit 3db4ee1aab
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -71,6 +71,8 @@ export default class App extends Vue {
error: Error | null = null;
online = true;
async created(): Promise<void> {
if (await this.initializeCurrentUser()) {
await initializeCurrentActor(this.$apollo.provider.defaultClient);
@ -100,6 +102,23 @@ export default class App extends Vue {
}
return false;
}
mounted(): void {
this.online = window.navigator.onLine;
window.addEventListener("offline", () => {
this.online = false;
this.showOfflineNetworkWarning();
console.log("offline");
});
window.addEventListener("online", () => {
this.online = true;
console.log("online");
});
}
showOfflineNetworkWarning(): void {
this.$notifier.error(this.$t("You are offline") as string);
}
}
</script>