Fix push notification settings not appearing when not subscribed
This commit is contained in:
parent
2f8126d732
commit
dc80c1dba3
|
@ -8,19 +8,22 @@ export default (): void => {
|
||||||
const notificationCapable = document.body.classList.contains('cap-notification');
|
const notificationCapable = document.body.classList.contains('cap-notification');
|
||||||
|
|
||||||
if (swCapable && notificationCapable) {
|
if (swCapable && notificationCapable) {
|
||||||
|
const enableBtn = document.querySelector('button[data-action="push-enable"]');
|
||||||
|
|
||||||
navigator.serviceWorker.getRegistration().then(registration => {
|
if (!enableBtn) return;
|
||||||
return registration.pushManager.getSubscription().then(subscription => {
|
|
||||||
if (!subscription) {
|
enableBtn.classList.remove('d-none');
|
||||||
document.querySelector('button[data-action="push-enable"]').classList.remove('d-none');
|
|
||||||
} else {
|
navigator.serviceWorker.getRegistration().then(registration =>
|
||||||
|
registration?.pushManager.getSubscription().then(subscription => {
|
||||||
|
if (subscription) {
|
||||||
|
document.querySelector('button[data-action="push-enable"]').classList.add('d-none');
|
||||||
document.querySelector('[data-action="push-disable"]').classList.remove('d-none');
|
document.querySelector('[data-action="push-disable"]').classList.remove('d-none');
|
||||||
if (localStorage.getItem('dismiss-push-settings-prompt') == null) {
|
if (localStorage.getItem('dismiss-push-settings-prompt') == null) {
|
||||||
document.querySelector('.push-settings')?.classList.remove('d-none');
|
document.querySelector('.push-settings')?.classList.remove('d-none');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registerEvents([
|
registerEvents([
|
||||||
|
|
Loading…
Reference in New Issue