feat: reduce amount of big cards for follow notifications

This commit is contained in:
patak 2022-12-14 00:06:53 +01:00
parent 089890677f
commit 1f5b0cf5ef
2 changed files with 40 additions and 18 deletions

View file

@ -40,12 +40,22 @@ function groupItems(items: Notification[]): NotificationSlot[] {
// Only group follow notifications when there are too many in a row
// This normally happens when you transfer an account, if not, show
// a big profile card for each follow
if (group[0].type === 'follow' && group.length > minFollowGroupSize) {
results.push({
id: `grouped-${id++}`,
type: `grouped-${group[0].type}`,
items: group,
})
if (group[0].type === 'follow') {
const toGroup = []
for (const item of group) {
const hasHeader = !item.account.header.endsWith('/original/missing.png')
if (hasHeader && (item.account.followersCount > 250 || (group.length === 1 && item.account.followersCount > 25)))
results.push(item)
else
toGroup.push(item)
}
if (toGroup.length > 0) {
results.push({
id: `grouped-${id++}`,
type: `grouped-${group[0].type}`,
items: toGroup,
})
}
return
}