fix: repeat preprocessing notifications
removed some logic of a8e0e06d84
before,
re-add it now
This commit is contained in:
parent
333cab0858
commit
8d77f9e9fb
3 changed files with 29 additions and 7 deletions
|
@ -17,7 +17,7 @@ const {
|
|||
virtualScroller?: boolean
|
||||
stream?: Promise<WsEvents>
|
||||
eventType?: 'notification' | 'update'
|
||||
preprocess?: (items: T[]) => U[]
|
||||
preprocess?: (items: (U | T)[]) => U[]
|
||||
}>()
|
||||
|
||||
defineSlots<{
|
||||
|
|
|
@ -23,7 +23,7 @@ const groupId = (item: mastodon.v1.Notification): string => {
|
|||
return JSON.stringify(id)
|
||||
}
|
||||
|
||||
function preprocess(items: mastodon.v1.Notification[]): NotificationSlot[] {
|
||||
function groupItems(items: mastodon.v1.Notification[]): NotificationSlot[] {
|
||||
const results: NotificationSlot[] = []
|
||||
|
||||
let id = 0
|
||||
|
@ -108,6 +108,28 @@ function preprocess(items: mastodon.v1.Notification[]): NotificationSlot[] {
|
|||
return results
|
||||
}
|
||||
|
||||
function preprocess(items: NotificationSlot[]): NotificationSlot[] {
|
||||
const flattenedNotifications: mastodon.v1.Notification[] = []
|
||||
for (const item of items) {
|
||||
if (item.type === 'grouped-reblogs-and-favourites') {
|
||||
const group = item
|
||||
for (const like of group.likes) {
|
||||
if (like.reblog)
|
||||
flattenedNotifications.push(like.reblog)
|
||||
if (like.favourite)
|
||||
flattenedNotifications.push(like.favourite)
|
||||
}
|
||||
}
|
||||
else if (item.type === 'grouped-follow') {
|
||||
flattenedNotifications.push(...item.items)
|
||||
}
|
||||
else {
|
||||
flattenedNotifications.push(item)
|
||||
}
|
||||
}
|
||||
return groupItems(flattenedNotifications)
|
||||
}
|
||||
|
||||
const { clearNotifications } = useNotifications()
|
||||
const { formatNumber } = useHumanReadableNumber()
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue