forked from AkkomaGang/akkoma-fe
Add configuration to enable/disable web push notifications
This commit is contained in:
parent
ebe2a95140
commit
bbae2e10f3
2 changed files with 5 additions and 1 deletions
|
@ -23,6 +23,7 @@ const defaultState = {
|
||||||
likes: true,
|
likes: true,
|
||||||
repeats: true
|
repeats: true
|
||||||
},
|
},
|
||||||
|
webPushNotifications: true,
|
||||||
muteWords: [],
|
muteWords: [],
|
||||||
highlight: {},
|
highlight: {},
|
||||||
interfaceLanguage: browserLocale,
|
interfaceLanguage: browserLocale,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
function urlBase64ToUint8Array (base64String) {
|
function urlBase64ToUint8Array (base64String) {
|
||||||
const padding = '='.repeat((4 - base64String.length % 4) % 4)
|
const padding = '='.repeat((4 - base64String.length % 4) % 4)
|
||||||
const base64 = (base64String + padding)
|
const base64 = (base64String + padding)
|
||||||
|
@ -46,6 +45,10 @@ function askPermission () {
|
||||||
}
|
}
|
||||||
|
|
||||||
function subscribe (registration, store) {
|
function subscribe (registration, store) {
|
||||||
|
if (!store.rootState.config.webPushNotifications) {
|
||||||
|
return Promise.reject(new Error('Web Push is disabled in config'))
|
||||||
|
}
|
||||||
|
|
||||||
if (!store.rootState.instance.vapidPublicKey) {
|
if (!store.rootState.instance.vapidPublicKey) {
|
||||||
return Promise.reject(new Error('VAPID publick key is not found'))
|
return Promise.reject(new Error('VAPID publick key is not found'))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue