diff options
| author | Egor Kislitsyn <egor@kislitsyn.com> | 2018-12-07 18:13:04 +0700 |
|---|---|---|
| committer | Egor Kislitsyn <egor@kislitsyn.com> | 2018-12-07 18:13:04 +0700 |
| commit | 07f1b8523eddd596d154e68561a389d6b9742d95 (patch) | |
| tree | 9100eefe8f6cb787eb7646fc5e5b030f53f88f12 /src/services/push/push.js | |
| parent | 264da19f69479e83397fd716cab5527ee565ea7b (diff) | |
add subscribe module and fix race condition
Diffstat (limited to 'src/services/push/push.js')
| -rw-r--r-- | src/services/push/push.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/services/push/push.js b/src/services/push/push.js index ffab5918..923c2178 100644 --- a/src/services/push/push.js +++ b/src/services/push/push.js @@ -45,17 +45,17 @@ function askPermission () { } function subscribe (registration, store) { - if (!store.rootState.config.webPushNotifications) { + if (!store.state.config.webPushNotifications) { return Promise.reject(new Error('Web Push is disabled in config')) } - if (!store.rootState.instance.vapidPublicKey) { + if (!store.state.subscribe.vapidPublicKey) { return Promise.reject(new Error('VAPID public key is not found')) } const subscribeOptions = { userVisibleOnly: true, - applicationServerKey: urlBase64ToUint8Array(store.rootState.instance.vapidPublicKey) + applicationServerKey: urlBase64ToUint8Array(store.state.subscribe.vapidPublicKey) } return registration.pushManager.subscribe(subscribeOptions) } @@ -65,7 +65,7 @@ function sendSubscriptionToBackEnd (subscription, store) { method: 'POST', headers: { 'Content-Type': 'application/json', - 'Authorization': `Bearer ${store.rootState.oauth.token}` + 'Authorization': `Bearer ${store.state.subscribe.token}` }, body: JSON.stringify({ subscription, |
