improve push notifications code
This commit is contained in:
parent
11716a7a53
commit
73b17d70ec
3 changed files with 48 additions and 65 deletions
|
@ -12,16 +12,23 @@ const subscribe = {
|
|||
setVapidPublicKey (state, vapidPublicKey) {
|
||||
state.vapidPublicKey = vapidPublicKey
|
||||
}
|
||||
|
||||
},
|
||||
actions: {
|
||||
setInstanceOption (store, { name, value }) {
|
||||
store.commit('setVapidPublicKey', value)
|
||||
if (store.state.token) registerPushNotifications(this)
|
||||
if (name === 'vapidPublicKey') {
|
||||
store.commit('setVapidPublicKey', value)
|
||||
|
||||
if (store.state.token) {
|
||||
registerPushNotifications(store.rootState.config.webPushNotifications, value, store.state.token)
|
||||
}
|
||||
}
|
||||
},
|
||||
setCurrentUser (store, user) {
|
||||
store.commit('setApiToken', user.credentials)
|
||||
if (store.state.vapidPublicKey) registerPushNotifications(this)
|
||||
|
||||
if (store.state.vapidPublicKey) {
|
||||
registerPushNotifications(store.rootState.config.webPushNotifications, store.state.vapidPublicKey, user.credentials)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue