diff --git a/client/components/Windows/Settings.vue b/client/components/Windows/Settings.vue
index b8a0283b..ed33cc3e 100644
--- a/client/components/Windows/Settings.vue
+++ b/client/components/Windows/Settings.vue
@@ -264,8 +264,9 @@
id="pushNotifications"
type="button"
class="btn"
- disabled
+ :disabled="$root.pushNotificationState !== 'supported'"
data-text-alternate="Unsubscribe from push notifications"
+ @click="onPushButtonClick"
>Subscribe to push notifications
diff --git a/client/js/webpush.js b/client/js/webpush.js
index 4e757cf1..5b55b8aa 100644
--- a/client/js/webpush.js
+++ b/client/js/webpush.js
@@ -67,13 +67,16 @@ module.exports.initialize = () => {
alternatePushButton();
}
});
- }).catch(() => {
- vueApp.pushNotificationState = "unsupported";
- });
+ })
+ .catch(() => {
+ vueApp.pushNotificationState = "unsupported";
+ });
}
};
-function onPushButton() {
+module.exports.onPushButton = () => {
+ // TODO: move dom logic to Settings.vue
+ pushNotificationsButton = $("#pushNotifications");
pushNotificationsButton.prop("disabled", true);
navigator.serviceWorker.ready
@@ -127,7 +130,7 @@ function onPushButton() {
});
return false;
-}
+};
function alternatePushButton() {
const text = pushNotificationsButton.text();