From 3db4ee1aabc8e8096a23da39645a6fb5b996c0b8 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 12 May 2021 18:10:33 +0200 Subject: [PATCH] Warn when offline Signed-off-by: Thomas Citharel --- js/src/App.vue | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/js/src/App.vue b/js/src/App.vue index b8c29a98..f3e75139 100644 --- a/js/src/App.vue +++ b/js/src/App.vue @@ -71,6 +71,8 @@ export default class App extends Vue { error: Error | null = null; + online = true; + async created(): Promise { 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); + } }