Actually fix notifications

This commit is contained in:
Essem 2025-03-05 01:01:01 -06:00
commit 5e917152f6
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
3 changed files with 7 additions and 5 deletions

View file

@ -349,7 +349,6 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot
// Only add a new notification if we don't have one for the same action
if (!state.notifications.idStore.hasOwnProperty(notification.id)) {
updateNotificationsMinMaxId(state, notification)
notification.seen = false
state.notifications.data.push(notification)
state.notifications.idStore[notification.id] = notification

View file

@ -775,7 +775,7 @@ const fetchTimeline = ({
let statusText = ''
let pagination = {}
return fetch(url, { headers: authHeaders(credentials) })
return markerPromise.then(() => fetch(url, { headers: authHeaders(credentials) }))
.then((data) => {
status = data.status
statusText = data.statusText
@ -794,7 +794,10 @@ const fetchTimeline = ({
throw new Error(data.error)
}
if (!data.errors) {
if (isNotifications) data.map((val) => val.last_read = markers.last_read_id)
if (isNotifications) data = data.map((val) => {
val.last_read = markers.last_read_id
return val
})
return { data: data.map(isNotifications ? parseNotification : parseStatus), pagination }
} else {
data.status = status

View file

@ -1,4 +1,4 @@
import { filter, sortBy, includes } from 'lodash'
import { filter, orderBy, includes } from 'lodash'
import { muteWordHits } from '../status_parser/status_parser.js'
import { showDesktopNotification } from '../desktop_notification_utils/desktop_notification_utils.js'
@ -65,7 +65,7 @@ export const maybeShowNotification = (store, notification) => {
export const filteredNotificationsFromStore = (store, types) => {
// map is just to clone the array since sort mutates it and it causes some issues
let sortedNotifications = notificationsFromStore(store).map(_ => _).sort(sortById)
sortedNotifications = sortBy(sortedNotifications, 'seen')
sortedNotifications = orderBy(sortedNotifications, 'id', 'desc')
return sortedNotifications.filter(
(notification) => (types || visibleTypes(store)).includes(notification.type)
)