aboutsummaryrefslogtreecommitdiff
path: root/src/modules/pushNotifications.js
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2018-12-09 19:25:43 +0700
committerEgor Kislitsyn <egor@kislitsyn.com>2018-12-09 19:25:43 +0700
commit73b17d70ec3a9b1d73789c236601628bfa8c498b (patch)
treedf3bf918be7907fecb1d0a3819e719658f8bac1b /src/modules/pushNotifications.js
parent11716a7a5381c8f4fe06c869a4a21c52a2120e6c (diff)
improve push notifications code
Diffstat (limited to 'src/modules/pushNotifications.js')
-rw-r--r--src/modules/pushNotifications.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/modules/pushNotifications.js b/src/modules/pushNotifications.js
index 43143b1f..ea92f811 100644
--- a/src/modules/pushNotifications.js
+++ b/src/modules/pushNotifications.js
@@ -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)
+ }
}
}
}