Warn when offline
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
d19de15c11
commit
3db4ee1aab
|
@ -71,6 +71,8 @@ export default class App extends Vue {
|
||||||
|
|
||||||
error: Error | null = null;
|
error: Error | null = null;
|
||||||
|
|
||||||
|
online = true;
|
||||||
|
|
||||||
async created(): Promise<void> {
|
async created(): Promise<void> {
|
||||||
if (await this.initializeCurrentUser()) {
|
if (await this.initializeCurrentUser()) {
|
||||||
await initializeCurrentActor(this.$apollo.provider.defaultClient);
|
await initializeCurrentActor(this.$apollo.provider.defaultClient);
|
||||||
|
@ -100,6 +102,23 @@ export default class App extends Vue {
|
||||||
}
|
}
|
||||||
return false;
|
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>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue