diff --git a/client/components/App.vue b/client/components/App.vue
index 211b785a..01e3f558 100644
--- a/client/components/App.vue
+++ b/client/components/App.vue
@@ -19,44 +19,42 @@
Warning No settings have been synced before. Enabling this will sync all settings of this client as the base for other clients.
Loading…
"); diff --git a/client/js/vue.js b/client/js/vue.js index 3171e328..5bede74f 100644 --- a/client/js/vue.js +++ b/client/js/vue.js @@ -25,6 +25,9 @@ const vueApp = new Vue({ isFileUploadEnabled: false, isNotified: false, networks: [], + pushNotificationState: "unsupported", + desktopNotificationState: "unsupported", + serverConfiguration: {}, settings: { syncSettings: false, advanced: false, diff --git a/client/js/webpush.js b/client/js/webpush.js index 24272e7f..4e757cf1 100644 --- a/client/js/webpush.js +++ b/client/js/webpush.js @@ -3,6 +3,7 @@ const $ = require("jquery"); const storage = require("./localStorage"); const socket = require("./socket"); +const {vueApp} = require("./vue"); let pushNotificationsButton; let clientSubscribed = null; @@ -43,11 +44,10 @@ module.exports.initialize = () => { pushNotificationsButton = $("#pushNotifications"); if (!isAllowedServiceWorkersHost()) { + vueApp.pushNotificationState = "nohttps"; return; } - $("#pushNotificationsHttps").hide(); - if ("serviceWorker" in navigator) { navigator.serviceWorker .register("service-worker.js") @@ -59,9 +59,7 @@ module.exports.initialize = () => { } return registration.pushManager.getSubscription().then((subscription) => { - $("#pushNotificationsUnsupported").hide(); - - pushNotificationsButton.prop("disabled", false).on("click", onPushButton); + vueApp.pushNotificationState = "supported"; clientSubscribed = !!subscription; @@ -69,10 +67,9 @@ module.exports.initialize = () => { alternatePushButton(); } }); - }) - .catch((err) => { - $("#pushNotificationsUnsupported span").text(err); - }); + }).catch(() => { + vueApp.pushNotificationState = "unsupported"; + }); } }; @@ -126,11 +123,7 @@ function onPushButton() { }) ) .catch((err) => { - $("#pushNotificationsUnsupported") - .find("span") - .text(`An error has occurred: ${err}`) - .end() - .show(); + vueApp.pushNotificationState = "unsupported"; }); return false;