Fix Safari Profile page (#1619)

This commit is contained in:
Paulus Schoutsen 2018-08-31 11:17:57 +02:00 committed by GitHub
parent da19a1a9c6
commit 18a151c8e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,10 +45,13 @@ class HaPushNotificationsToggle extends EventsMixin(PolymerElement) {
async connectedCallback() {
super.connectedCallback();
if (!('serviceWorker' in navigator)) return;
if (!pushSupported) return;
try {
const reg = await navigator.serviceWorker.ready;
if (!reg.pushManager) {
return;
}
reg.pushManager.getSubscription().then((subscription) => {
this.loading = false;
this.pushChecked = !!subscription;
@ -59,6 +62,10 @@ class HaPushNotificationsToggle extends EventsMixin(PolymerElement) {
}
handlePushChange(pushChecked) {
// Somehow this is triggered on Safari on page load causing
// it to get into a loop and crash the page.
if (!pushSupported) return;
if (pushChecked) {
this.subscribePushNotifications();
} else {