Fix enabling and disabling push notifications.
This commit is contained in:
parent
467ebab31f
commit
7fd48d8155
@ -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</button>
|
||||
<div
|
||||
v-if="$root.pushNotificationState === 'nohttps'"
|
||||
@ -533,6 +534,10 @@ export default {
|
||||
if (window.navigator.registerProtocolHandler) {
|
||||
this.canRegisterProtocol = true;
|
||||
}
|
||||
|
||||
// TODO: Rework push notification code to avoid reinitializing it here
|
||||
const webpush = require("../../js/webpush");
|
||||
webpush.initialize();
|
||||
},
|
||||
methods: {
|
||||
onChange(event) {
|
||||
@ -603,6 +608,10 @@ export default {
|
||||
pop.src = "audio/pop.wav";
|
||||
pop.play();
|
||||
},
|
||||
onPushButtonClick() {
|
||||
const webpush = require("../../js/webpush"); // TODO: do this in a smarter way
|
||||
webpush.onPushButton();
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user