MCPcopy
hub / github.com/gitify-app/gitify / getNewNotifications

Function getNewNotifications

src/renderer/utils/notifications/utils.ts:8–31  ·  view source on GitHub ↗
(
  previousAccountNotifications: AccountNotifications[],
  newAccountNotifications: AccountNotifications[],
)

Source from the content-addressed store, hash-verified

6 * Find notifications that exist in newNotifications but not in previousNotifications
7 */
8export function getNewNotifications(
9 previousAccountNotifications: AccountNotifications[],
10 newAccountNotifications: AccountNotifications[],
11): GitifyNotification[] {
12 return newAccountNotifications.flatMap((accountNotifications) => {
13 const accountPreviousNotifications = previousAccountNotifications.find(
14 (item) =>
15 getAccountUUID(item.account) ===
16 getAccountUUID(accountNotifications.account),
17 );
18
19 if (!accountPreviousNotifications) {
20 return accountNotifications.notifications;
21 }
22
23 const previousIds = new Set(
24 accountPreviousNotifications.notifications.map((item) => item.id),
25 );
26
27 return accountNotifications.notifications.filter(
28 (notification) => !previousIds.has(notification.id),
29 );
30 });
31}

Callers 2

utils.test.tsFile · 0.90
useNotificationsFunction · 0.90

Calls 1

getAccountUUIDFunction · 0.90

Tested by

no test coverage detected