2022-09-11 11:42:40 -07:00
|
|
|
import registerEvents from 'retrospring/utilities/registerEvents';
|
|
|
|
import { enableHandler } from './enable';
|
|
|
|
import { dismissHandler } from "./dismiss";
|
|
|
|
|
|
|
|
export default (): void => {
|
2022-10-20 09:49:02 -07:00
|
|
|
const swCapable = document.body.classList.contains('cap-service-worker');
|
|
|
|
const notificationCapable = document.body.classList.contains('cap-notification');
|
2022-09-11 11:42:40 -07:00
|
|
|
|
|
|
|
if (swCapable && notificationCapable) {
|
|
|
|
navigator.serviceWorker.getRegistration().then(registration => {
|
|
|
|
if (!registration && localStorage.getItem('dismiss-push-settings-prompt') == null) {
|
|
|
|
document.querySelector('.push-settings').classList.remove('d-none');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
registerEvents([
|
|
|
|
{type: 'click', target: '[data-action="push-enable"]', handler: enableHandler, global: true},
|
|
|
|
{type: 'click', target: '[data-action="push-dismiss"]', handler: dismissHandler, global: true},
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|