diff options
Diffstat (limited to 'src/modules/subscribe.js')
| -rw-r--r-- | src/modules/subscribe.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/modules/subscribe.js b/src/modules/subscribe.js new file mode 100644 index 00000000..e705904c --- /dev/null +++ b/src/modules/subscribe.js @@ -0,0 +1,21 @@ +import registerPushNotifications from '../services/push/push.js' + +const subscribe = { + state: { + token: null, + vapidPublicKey: null + }, + mutations: { + setCurrentUser (state, user) { + state.token = user.credentials + if (state.token && state.vapidPublicKey) registerPushNotifications(this) + }, + setInstanceOption (state, { name, value }) { + if (name !== 'vapidPublicKey') return + state.vapidPublicKey = value + if (state.token && state.vapidPublicKey) registerPushNotifications(this) + } + } +} + +export default subscribe |
