From 73b17d70ec3a9b1d73789c236601628bfa8c498b Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Sun, 9 Dec 2018 19:25:43 +0700 Subject: improve push notifications code --- src/modules/pushNotifications.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/modules/pushNotifications.js') 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) + } } } } -- cgit v1.2.3-70-g09d2