aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/ConnectivityChecker.vue25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/components/ConnectivityChecker.vue b/src/components/ConnectivityChecker.vue
index 02cbd7f..a717bcf 100644
--- a/src/components/ConnectivityChecker.vue
+++ b/src/components/ConnectivityChecker.vue
@@ -29,15 +29,40 @@ export default {
29 }, 29 },
30 false 30 false
31 ); 31 );
32 window.addEventListener(
33 "online",
34 function () {
35 that.checkOffline();
36 },
37 false
38 );
39 window.addEventListener(
40 "offline",
41 function () {
42 this.offline = true;
43 },
44 false
45 );
32 }, 46 },
33 methods: { 47 methods: {
34 checkOffline: function () { 48 checkOffline: function () {
49 if (!navigator.onLine) {
50 this.offline = true;
51 return;
52 }
53
54 // extra check to make sure we're not offline
35 let that = this; 55 let that = this;
36 return fetch(window.location.href + "?alive", { 56 return fetch(window.location.href + "?alive", {
37 method: "HEAD", 57 method: "HEAD",
38 cache: "no-store", 58 cache: "no-store",
59 redirect: "manual"
39 }) 60 })
40 .then(function (response) { 61 .then(function (response) {
62 // opaqueredirect means request has been redirected, to auth provider probably
63 if (response.type === "opaqueredirect" && !response.ok) {
64 window.location.reload(true);
65 }
41 that.offline = !response.ok; 66 that.offline = !response.ok;
42 }) 67 })
43 .catch(function () { 68 .catch(function () {