2018-10-06 22:06:10 +02:00
|
|
|
export function notificationPermissionObservers (store) {
|
2018-11-05 17:28:38 +01:00
|
|
|
if (!process.browser || !navigator.permissions || !navigator.permissions.query) {
|
2018-10-06 22:06:10 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
navigator.permissions.query({ name: 'notifications' }).then(permission => {
|
|
|
|
store.set({ notificationPermission: permission.state })
|
|
|
|
|
|
|
|
permission.onchange = event => {
|
|
|
|
store.set({ notificationPermission: event.target.state })
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|