diff --git a/pkg/interface/src/logic/lib/hark.ts b/pkg/interface/src/logic/lib/hark.ts index 2e7a6b3d9e..d6a2ed3890 100644 --- a/pkg/interface/src/logic/lib/hark.ts +++ b/pkg/interface/src/logic/lib/hark.ts @@ -1,6 +1,6 @@ import bigInt, { BigInteger } from 'big-integer'; import f from 'lodash/fp'; -import { Unreads, NotificationGraphConfig } from '@urbit/api'; +import { Unreads, NotificationGraphConfig, IndexedNotification } from '@urbit/api'; export function getLastSeen( unreads: Unreads, @@ -44,3 +44,16 @@ export function isWatching( watch => watch.graph === graph && watch.index === index ); } + +export function getNotificationKey(time: BigInteger, notification: IndexedNotification): string { + const base = time.toString(); + if('graph' in notification.index) { + const { graph, index } = notification.index.graph; + return `${base}-${graph}-${index}`; + } else if('group' in notification.index) { + const { group } = notification.index.group; + return `${base}-${group}`; + } + return `${base}-unknown`; +} + diff --git a/pkg/interface/src/views/apps/notifications/inbox.tsx b/pkg/interface/src/views/apps/notifications/inbox.tsx index 1746376afc..52accda396 100644 --- a/pkg/interface/src/views/apps/notifications/inbox.tsx +++ b/pkg/interface/src/views/apps/notifications/inbox.tsx @@ -26,6 +26,7 @@ import { useLazyScroll } from '~/logic/lib/useLazyScroll'; import useHarkState from '~/logic/state/hark'; import useInviteState from '~/logic/state/invite'; import useMetadataState from '~/logic/state/metadata'; +import {getNotificationKey} from '~/logic/lib/hark'; type DatedTimebox = [BigInteger, Timebox]; @@ -121,13 +122,14 @@ export default function Inbox(props: { ); return ( - + {[...notificationsByDayMap.keys()].sort().reverse().map((day, index) => { const timeboxes = notificationsByDayMap.get(day)!; return timeboxes.length > 0 && ( nots.length).reduce(f.add, 0); @@ -178,7 +181,7 @@ function DaySection({ {_.map(timeboxes.sort(sortTimeboxes), ([date, nots], i: number) => _.map(nots.sort(sortIndexedNotification), (not, j: number) => (