diff options
Diffstat (limited to 'src/modules/users.js')
| -rw-r--r-- | src/modules/users.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/modules/users.js b/src/modules/users.js index f2b59aaa..2f05ed3f 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -66,6 +66,9 @@ export const mutations = { setUserForStatus (state, status) { status.user = state.usersObject[status.user.id] }, + setUserForNotification (state, notification) { + notification.action.user = state.usersObject[notification.action.user.id] + }, setColor (state, { user: { id }, highlighted }) { const user = state.usersObject[id] set(user, 'highlight', highlighted) @@ -113,8 +116,9 @@ const users = { const token = store.state.currentUser.credentials const vapidPublicKey = store.rootState.instance.vapidPublicKey const isEnabled = store.rootState.config.webPushNotifications + const notificationVisibility = store.rootState.config.notificationVisibility - registerPushNotifications(isEnabled, vapidPublicKey, token) + registerPushNotifications(isEnabled, vapidPublicKey, token, notificationVisibility) }, unregisterPushNotifications (store) { const token = store.state.currentUser.credentials @@ -136,6 +140,21 @@ const users = { store.commit('setUserForStatus', status) }) }, + addNewNotifications (store, { notifications }) { + const users = compact(map(notifications, 'from_profile')) + const notificationIds = compact(notifications.map(_ => String(_.id))) + store.commit('addNewUsers', users) + + const notificationsObject = store.rootState.statuses.notifications.idStore + const relevantNotifications = Object.entries(notificationsObject) + .filter(([k, val]) => notificationIds.includes(k)) + .map(([k, val]) => val) + + // Reconnect users to notifications + each(relevantNotifications, (notification) => { + store.commit('setUserForNotification', notification) + }) + }, async signUp (store, userInfo) { store.commit('signUpPending') |
