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

Function getAllNotifications

src/renderer/utils/notifications/notifications.ts:83–139  ·  view source on GitHub ↗
(
  state: GitifyState,
)

Source from the content-addressed store, hash-verified

81 * @returns A promise that resolves to an array of account notifications.
82 */
83export async function getAllNotifications(
84 state: GitifyState,
85): Promise<AccountNotifications[]> {
86 if (!state.auth || !state.settings) {
87 return [];
88 }
89
90 const { auth, settings } = state;
91
92 const accountNotifications: AccountNotifications[] = await Promise.all(
93 getNotifications(auth, settings)
94 .filter((response) => !!response)
95 .map(async (accountNotifications) => {
96 try {
97 const rawNotifications = await accountNotifications.notifications;
98
99 let notifications = transformNotifications(
100 rawNotifications,
101 accountNotifications.account,
102 );
103
104 notifications = filterBaseNotifications(notifications);
105
106 notifications = await enrichNotifications(notifications, settings);
107
108 notifications = filterDetailedNotifications(notifications, settings);
109
110 notifications = notifications.map((notification) => {
111 return formatNotification(notification);
112 });
113
114 return {
115 account: accountNotifications.account,
116 notifications: notifications,
117 error: null,
118 };
119 } catch (err) {
120 rendererLogError(
121 'getAllNotifications',
122 'error occurred while fetching account notifications',
123 toError(err),
124 );
125
126 return {
127 account: accountNotifications.account,
128 notifications: [],
129 error: determineFailureType(toError(err)),
130 };
131 }
132 }),
133 );
134
135 // Set the order property for the notifications
136 stabilizeNotificationsOrder(accountNotifications, settings);
137
138 return accountNotifications;
139}
140

Callers 1

useNotificationsFunction · 0.90

Calls 10

transformNotificationsFunction · 0.90
filterBaseNotificationsFunction · 0.90
formatNotificationFunction · 0.90
rendererLogErrorFunction · 0.90
toErrorFunction · 0.90
determineFailureTypeFunction · 0.90
getNotificationsFunction · 0.85
enrichNotificationsFunction · 0.85

Tested by

no test coverage detected