From 80c11f2bdeb5060f7002f59591df8ab9a915c6a9 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sun, 24 Dec 2017 22:04:27 +0200 Subject: [PATCH] Fix error not showing up in failed push subscription --- client/js/webpush.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/js/webpush.js b/client/js/webpush.js index bffe65c7..48d4f17b 100644 --- a/client/js/webpush.js +++ b/client/js/webpush.js @@ -68,7 +68,7 @@ module.exports.initialize = () => { function onPushButton() { pushNotificationsButton.attr("disabled", true); - navigator.serviceWorker.ready.then((registration) => { + navigator.serviceWorker.ready.then((registration) => registration.pushManager.getSubscription().then((existingSubscription) => { if (existingSubscription) { socket.emit("push:unregister"); @@ -100,9 +100,11 @@ function onPushButton() { if (successful) { alternatePushButton().removeAttr("disabled"); } - }); - }).catch((err) => { - $("#pushNotificationsUnsupported span").text(err).show(); + }) + ).catch((err) => { + $("#pushNotificationsUnsupported") + .find("span").text(`An error has occured: ${err}`).end() + .show(); }); return false;