Notifications: More reduxification.
This commit is contained in:
parent
6074f16f9b
commit
70db485a58
|
@ -133,7 +133,7 @@
|
||||||
@{{ notification.redux.account.redux.acct }}
|
@{{ notification.redux.account.redux.acct }}
|
||||||
</router-link>
|
</router-link>
|
||||||
<div
|
<div
|
||||||
v-if="notification.type === 'follow_request'"
|
v-if="notification.redux.type === 'follow_request'"
|
||||||
style="white-space: nowrap;"
|
style="white-space: nowrap;"
|
||||||
>
|
>
|
||||||
<i
|
<i
|
||||||
|
@ -149,17 +149,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-else-if="notification.type === 'move'"
|
v-else-if="notification.redux.type === 'move'"
|
||||||
class="move-text"
|
class="move-text"
|
||||||
>
|
>
|
||||||
<router-link :to="targetUserProfileLink">
|
<router-link :to="targetUserProfileLink">
|
||||||
@{{ notification.target.redux.acct }}
|
@{{ notification.redux.target.redux.acct }}
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<status-content
|
<status-content
|
||||||
class="faint"
|
class="faint"
|
||||||
:status="notification.status"
|
:status="notification.redux.status"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
omitBy
|
omitBy
|
||||||
} from 'lodash'
|
} from 'lodash'
|
||||||
import { set } from 'vue'
|
import { set } from 'vue'
|
||||||
import { isStatusNotification, prepareNotificationObject } from '../services/notification_utils/notification_utils.js'
|
import { isStatusNotification, prepareNotificationObject, visibleTypes } from '../services/notification_utils/notification_utils.js'
|
||||||
import apiService from '../services/api/api.service.js'
|
import apiService from '../services/api/api.service.js'
|
||||||
import { muteWordHits } from '../services/status_parser/status_parser.js'
|
import { muteWordHits } from '../services/status_parser/status_parser.js'
|
||||||
|
|
||||||
|
@ -76,17 +76,6 @@ export const prepareStatus = (status) => {
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
|
||||||
const visibleNotificationTypes = (rootState) => {
|
|
||||||
return [
|
|
||||||
rootState.config.notificationVisibility.likes && 'like',
|
|
||||||
rootState.config.notificationVisibility.mentions && 'mention',
|
|
||||||
rootState.config.notificationVisibility.repeats && 'repeat',
|
|
||||||
rootState.config.notificationVisibility.follows && 'follow',
|
|
||||||
rootState.config.notificationVisibility.moves && 'move',
|
|
||||||
rootState.config.notificationVisibility.emojiReactions && 'pleroma:emoji_reactions'
|
|
||||||
].filter(_ => _)
|
|
||||||
}
|
|
||||||
|
|
||||||
const mergeOrAdd = (arr, obj, item) => {
|
const mergeOrAdd = (arr, obj, item) => {
|
||||||
const oldItem = obj[item.id]
|
const oldItem = obj[item.id]
|
||||||
|
|
||||||
|
@ -323,12 +312,11 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
|
||||||
const addNewNotifications = (state, { dispatch, notifications, older, visibleNotificationTypes, rootGetters }) => {
|
const addNewNotifications = (state, { dispatch, notifications, older, visibleNotificationTypes, rootGetters }) => {
|
||||||
each(notifications, (notification) => {
|
each(notifications, (notification) => {
|
||||||
if (isStatusNotification(notification.type)) {
|
if (isStatusNotification(notification.type)) {
|
||||||
notification.action = addStatusToGlobalStorage(state, notification.action).item
|
notification.redux.status = notification.redux.status && addStatusToGlobalStorage(state, notification.redux.status).item
|
||||||
notification.status = notification.status && addStatusToGlobalStorage(state, notification.status).item
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notification.type === 'pleroma:emoji_reaction') {
|
if (notification.redux.type === 'pleroma:emoji_reaction') {
|
||||||
dispatch('fetchEmojiReactionsBy', notification.status.id)
|
dispatch('fetchEmojiReactionsBy', notification.redux.status.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only add a new notification if we don't have one for the same action
|
// Only add a new notification if we don't have one for the same action
|
||||||
|
@ -347,11 +335,11 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot
|
||||||
const notifObj = prepareNotificationObject(notification, rootGetters.i18n)
|
const notifObj = prepareNotificationObject(notification, rootGetters.i18n)
|
||||||
|
|
||||||
const reasonsToMuteNotif = (
|
const reasonsToMuteNotif = (
|
||||||
notification.seen ||
|
notification.redux.is_seen ||
|
||||||
state.notifications.desktopNotificationSilence ||
|
state.notifications.desktopNotificationSilence ||
|
||||||
!visibleNotificationTypes.includes(notification.type) ||
|
!visibleNotificationTypes.includes(notification.redux.type) ||
|
||||||
(
|
(
|
||||||
notification.type === 'mention' && status && (
|
notification.redux.type === 'mention' && status && (
|
||||||
status.muted ||
|
status.muted ||
|
||||||
muteWordHits(status, rootGetters.mergedConfig.muteWords).length === 0
|
muteWordHits(status, rootGetters.mergedConfig.muteWords).length === 0
|
||||||
)
|
)
|
||||||
|
@ -364,7 +352,7 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot
|
||||||
setTimeout(desktopNotification.close.bind(desktopNotification), 5000)
|
setTimeout(desktopNotification.close.bind(desktopNotification), 5000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (notification.seen) {
|
} else if (notification.redux.is_seen) {
|
||||||
state.notifications.idStore[notification.id].seen = true
|
state.notifications.idStore[notification.id].seen = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -589,7 +577,7 @@ const statuses = {
|
||||||
commit('addNewStatuses', { statuses, showImmediately, timeline, noIdUpdate, user: rootState.users.currentUser, userId })
|
commit('addNewStatuses', { statuses, showImmediately, timeline, noIdUpdate, user: rootState.users.currentUser, userId })
|
||||||
},
|
},
|
||||||
addNewNotifications ({ rootState, commit, dispatch, rootGetters }, { notifications, older }) {
|
addNewNotifications ({ rootState, commit, dispatch, rootGetters }, { notifications, older }) {
|
||||||
commit('addNewNotifications', { visibleNotificationTypes: visibleNotificationTypes(rootState), dispatch, notifications, older, rootGetters })
|
commit('addNewNotifications', { visibleNotificationTypes: visibleTypes(rootState), dispatch, notifications, older, rootGetters })
|
||||||
},
|
},
|
||||||
setError ({ rootState, commit }, { value }) {
|
setError ({ rootState, commit }, { value }) {
|
||||||
commit('setError', { value })
|
commit('setError', { value })
|
||||||
|
|
|
@ -2,14 +2,14 @@ import { filter, sortBy, includes } from 'lodash'
|
||||||
|
|
||||||
export const notificationsFromStore = store => store.state.statuses.notifications.data
|
export const notificationsFromStore = store => store.state.statuses.notifications.data
|
||||||
|
|
||||||
export const visibleTypes = store => ([
|
export const visibleTypes = state => ([
|
||||||
store.state.config.notificationVisibility.likes && 'like',
|
state.config.notificationVisibility.likes && 'favourite',
|
||||||
store.state.config.notificationVisibility.mentions && 'mention',
|
state.config.notificationVisibility.mentions && 'mention',
|
||||||
store.state.config.notificationVisibility.repeats && 'repeat',
|
state.config.notificationVisibility.repeats && 'reblog',
|
||||||
store.state.config.notificationVisibility.follows && 'follow',
|
state.config.notificationVisibility.follows && 'follow',
|
||||||
store.state.config.notificationVisibility.followRequest && 'follow_request',
|
state.config.notificationVisibility.followRequest && 'follow_request',
|
||||||
store.state.config.notificationVisibility.moves && 'move',
|
state.config.notificationVisibility.moves && 'move',
|
||||||
store.state.config.notificationVisibility.emojiReactions && 'pleroma:emoji_reaction'
|
state.config.notificationVisibility.emojiReactions && 'pleroma:emoji_reaction'
|
||||||
].filter(_ => _))
|
].filter(_ => _))
|
||||||
|
|
||||||
const statusNotifications = ['like', 'mention', 'repeat', 'pleroma:emoji_reaction']
|
const statusNotifications = ['like', 'mention', 'repeat', 'pleroma:emoji_reaction']
|
||||||
|
@ -37,7 +37,7 @@ export const filteredNotificationsFromStore = (store, types) => {
|
||||||
let sortedNotifications = notificationsFromStore(store).map(_ => _).sort(sortById)
|
let sortedNotifications = notificationsFromStore(store).map(_ => _).sort(sortById)
|
||||||
sortedNotifications = sortBy(sortedNotifications, 'seen')
|
sortedNotifications = sortBy(sortedNotifications, 'seen')
|
||||||
return sortedNotifications.filter(
|
return sortedNotifications.filter(
|
||||||
(notification) => (types || visibleTypes(store)).includes(notification.type)
|
(notification) => (types || visibleTypes(store.state)).includes(notification.type)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue