aboutsummaryrefslogtreecommitdiff
path: root/src/main.js
diff options
context:
space:
mode:
authorHJ <spam@hjkos.com>2018-12-26 13:58:11 +0000
committerHJ <spam@hjkos.com>2018-12-26 13:58:11 +0000
commit754cb23f354369d57dbe3f36e530709850ae7028 (patch)
tree484896a753c447ec5016990611724c16860dd0a0 /src/main.js
parent9ba969d90c6f464c58e4ed0fe48401574c68b8a6 (diff)
parentc5847349e0afb14702d1746fac142b8aeb2020e7 (diff)
Merge branch 'improve_push' into 'develop'
Improve web push notifications Closes #231 See merge request pleroma/pleroma-fe!438
Diffstat (limited to 'src/main.js')
-rw-r--r--src/main.js25
1 files changed, 2 insertions, 23 deletions
diff --git a/src/main.js b/src/main.js
index c22a762e..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,28 +52,6 @@ const persistedStateOptions = {
]
}
-const registerPushNotifications = store => {
- store.subscribe((mutation, state) => {
- const vapidPublicKey = state.instance.vapidPublicKey
- const webPushNotification = state.config.webPushNotifications
- const permission = state.interface.notificationPermission === 'granted'
- const user = state.users.currentUser
-
- const isUserMutation = mutation.type === 'setCurrentUser'
- const isVapidMutation = mutation.type === 'setInstanceOption' && mutation.payload.name === 'vapidPublicKey'
- const isPermMutation = mutation.type === 'setNotificationPermission' && mutation.payload === 'granted'
- const isUserConfigMutation = mutation.type === 'setOption' && mutation.payload.name === 'webPushNotifications'
-
- if (isUserMutation || isVapidMutation || isPermMutation || isUserConfigMutation) {
- if (user && vapidPublicKey && permission && webPushNotification) {
- return store.dispatch('registerPushNotifications')
- } else if (isUserConfigMutation && !webPushNotification) {
- return store.dispatch('unregisterPushNotifications')
- }
- }
- })
-}
-
createPersistedState(persistedStateOptions).then((persistedState) => {
const store = new Vuex.Store({
modules: {
@@ -85,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'
})