Dont group notifications that are an hour apart

zio/stable
Paul Frazee 2022-11-18 15:38:20 -06:00
parent e02b39bf84
commit 39058cd36a
1 changed files with 5 additions and 0 deletions

View File

@ -8,6 +8,8 @@ import {cleanError} from '../../view/lib/strings'
const UNGROUPABLE_REASONS = ['trend', 'assertion'] const UNGROUPABLE_REASONS = ['trend', 'assertion']
const MS_60MIN = 1e3 * 60 * 60
export interface GroupedNotification extends ListNotifications.Notification { export interface GroupedNotification extends ListNotifications.Notification {
additional?: ListNotifications.Notification[] additional?: ListNotifications.Notification[]
} }
@ -344,10 +346,13 @@ function groupNotifications(
): GroupedNotification[] { ): GroupedNotification[] {
const items2: GroupedNotification[] = [] const items2: GroupedNotification[] = []
for (const item of items) { for (const item of items) {
const ts = +new Date(item.indexedAt)
let grouped = false let grouped = false
if (!UNGROUPABLE_REASONS.includes(item.reason)) { if (!UNGROUPABLE_REASONS.includes(item.reason)) {
for (const item2 of items2) { for (const item2 of items2) {
const ts2 = +new Date(item2.indexedAt)
if ( if (
Math.abs(ts2 - ts) < MS_60MIN &&
item.reason === item2.reason && item.reason === item2.reason &&
item.reasonSubject === item2.reasonSubject && item.reasonSubject === item2.reasonSubject &&
item.author.did !== item2.author.did item.author.did !== item2.author.did