Restore push notification prompt in inbox
This commit is contained in:
parent
1cfd3250c0
commit
fccf35fdab
|
@ -4,21 +4,20 @@ import { dismissHandler } from "./dismiss";
|
|||
import { unsubscribeHandler } from "retrospring/features/webpush/unsubscribe";
|
||||
|
||||
export default (): void => {
|
||||
const swCapable = document.body.classList.contains('cap-service-worker');
|
||||
const notificationCapable = document.body.classList.contains('cap-notification');
|
||||
const swCapable = 'serviceWorker' in navigator;
|
||||
const notificationCapable = 'Notification' in window;
|
||||
|
||||
if (swCapable && notificationCapable) {
|
||||
const enableBtn = document.querySelector('button[data-action="push-enable"]');
|
||||
|
||||
if (!enableBtn) return;
|
||||
|
||||
enableBtn.classList.remove('d-none');
|
||||
|
||||
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('button[data-action="push-enable"]')?.classList.add('d-none');
|
||||
document.querySelector('[data-action="push-disable"]')?.classList.remove('d-none');
|
||||
} else {
|
||||
enableBtn?.classList.remove('d-none');
|
||||
|
||||
if (localStorage.getItem('dismiss-push-settings-prompt') == null) {
|
||||
document.querySelector('.push-settings')?.classList.remove('d-none');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue