diff options
Diffstat (limited to 'src/main.js')
| -rw-r--r-- | src/main.js | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/src/main.js b/src/main.js index bf92e78e..f87ef9da 100644 --- a/src/main.js +++ b/src/main.js @@ -15,6 +15,7 @@ import VueTimeago from 'vue-timeago' import VueI18n from 'vue-i18n' import createPersistedState from './lib/persisted_state.js' +import pushNotifications from './lib/push_notifications_plugin.js' import messages from './i18n/messages.js' @@ -51,31 +52,6 @@ const persistedStateOptions = { ] } -const registerPushNotifications = store => { - store.subscribe((mutation, state) => { - const vapidPublicKey = state.instance.vapidPublicKey - const permission = state.interface.notificationPermission === 'granted' - const isUserMutation = mutation.type === 'setCurrentUser' - - if (isUserMutation && vapidPublicKey && permission) { - return store.dispatch('registerPushNotifications') - } - - const user = state.users.currentUser - const isVapidMutation = mutation.type === 'setInstanceOption' && mutation.payload.name === 'vapidPublicKey' - - if (isVapidMutation && user && permission) { - return store.dispatch('registerPushNotifications') - } - - const isPermMutation = mutation.type === 'setNotificationPermission' && mutation.payload === 'granted' - - if (isPermMutation && user && vapidPublicKey) { - return store.dispatch('registerPushNotifications') - } - }) -} - createPersistedState(persistedStateOptions).then((persistedState) => { const store = new Vuex.Store({ modules: { @@ -88,7 +64,7 @@ createPersistedState(persistedStateOptions).then((persistedState) => { chat: chatModule, oauth: oauthModule }, - plugins: [persistedState, registerPushNotifications], + plugins: [persistedState, pushNotifications], strict: false // Socket modifies itself, let's ignore this for now. // strict: process.env.NODE_ENV !== 'production' }) |
