fix notification dot in favicon and mobile nav, minor refactor
This commit is contained in:
parent
cdc0959135
commit
38b6f0a013
@ -8,7 +8,8 @@ import {
|
||||
notificationsFromStore,
|
||||
filteredNotificationsFromStore,
|
||||
unseenNotificationsFromStore,
|
||||
countExtraNotifications
|
||||
countExtraNotifications,
|
||||
ACTIONABLE_NOTIFICATION_TYPES
|
||||
} from '../../services/notification_utils/notification_utils.js'
|
||||
import FaviconService from '../../services/favicon_service/favicon_service.js'
|
||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||
@ -21,7 +22,6 @@ library.add(
|
||||
)
|
||||
|
||||
const DEFAULT_SEEN_TO_DISPLAY_COUNT = 30
|
||||
const ACTIONABLE_NOTIFICATION_TYPES = new Set(['mention', 'pleroma:report', 'follow_request'])
|
||||
|
||||
const Notifications = {
|
||||
components: {
|
||||
@ -85,11 +85,7 @@ const Notifications = {
|
||||
return `${this.unseenCount ? this.unseenCount : ''}${this.extraNotificationsCount ? '*' : ''}`
|
||||
},
|
||||
unseenCount () {
|
||||
if (this.ignoreInactionableSeen) {
|
||||
return this.unseenNotifications.filter(n => ACTIONABLE_NOTIFICATION_TYPES.has(n.type)).length
|
||||
} else {
|
||||
return this.unseenNotifications.length
|
||||
}
|
||||
},
|
||||
ignoreInactionableSeen () { return this.$store.getters.mergedConfig.ignoreInactionableSeen },
|
||||
extraNotificationsCount () {
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { filter, includes } from 'lodash'
|
||||
import { muteWordHits } from '../status_parser/status_parser.js'
|
||||
import { showDesktopNotification } from '../desktop_notification_utils/desktop_notification_utils.js'
|
||||
|
||||
import FaviconService from 'src/services/favicon_service/favicon_service.js'
|
||||
|
||||
export const ACTIONABLE_NOTIFICATION_TYPES = new Set(['mention', 'pleroma:report', 'follow_request'])
|
||||
|
||||
let cachedBadgeUrl = null
|
||||
|
||||
export const notificationsFromStore = store => store.state.notifications.data
|
||||
@ -24,9 +25,9 @@ export const visibleTypes = store => {
|
||||
].filter(_ => _))
|
||||
}
|
||||
|
||||
const statusNotifications = ['like', 'mention', 'repeat', 'pleroma:emoji_reaction', 'poll']
|
||||
const statusNotifications = new Set(['like', 'mention', 'repeat', 'pleroma:emoji_reaction', 'poll'])
|
||||
|
||||
export const isStatusNotification = (type) => includes(statusNotifications, type)
|
||||
export const isStatusNotification = (type) => statusNotifications.has(type)
|
||||
|
||||
export const isValidNotification = (notification) => {
|
||||
if (isStatusNotification(notification.type) && !notification.status) {
|
||||
@ -76,8 +77,15 @@ export const filteredNotificationsFromStore = (store, types) => {
|
||||
)
|
||||
}
|
||||
|
||||
export const unseenNotificationsFromStore = store =>
|
||||
filter(filteredNotificationsFromStore(store), ({ seen }) => !seen)
|
||||
export const unseenNotificationsFromStore = store => {
|
||||
const ignoreInactionableSeen = store.getters.mergedConfig.ignoreInactionableSeen
|
||||
|
||||
return filteredNotificationsFromStore(store).filter(({ seen, type }) => {
|
||||
if (!ignoreInactionableSeen) return !seen
|
||||
if (seen) return false
|
||||
return ACTIONABLE_NOTIFICATION_TYPES.has(type)
|
||||
})
|
||||
}
|
||||
|
||||
export const prepareNotificationObject = (notification, i18n) => {
|
||||
if (cachedBadgeUrl === null) {
|
||||
|
Loading…
Reference in New Issue
Block a user