mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-18 14:56:37 +00:00
Fix Safari Profile page (#1619)
This commit is contained in:
parent
da19a1a9c6
commit
18a151c8e8
@ -45,10 +45,13 @@ class HaPushNotificationsToggle extends EventsMixin(PolymerElement) {
|
|||||||
async connectedCallback() {
|
async connectedCallback() {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
|
|
||||||
if (!('serviceWorker' in navigator)) return;
|
if (!pushSupported) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const reg = await navigator.serviceWorker.ready;
|
const reg = await navigator.serviceWorker.ready;
|
||||||
|
if (!reg.pushManager) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
reg.pushManager.getSubscription().then((subscription) => {
|
reg.pushManager.getSubscription().then((subscription) => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.pushChecked = !!subscription;
|
this.pushChecked = !!subscription;
|
||||||
@ -59,6 +62,10 @@ class HaPushNotificationsToggle extends EventsMixin(PolymerElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handlePushChange(pushChecked) {
|
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) {
|
if (pushChecked) {
|
||||||
this.subscribePushNotifications();
|
this.subscribePushNotifications();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user