MCPcopy Index your code
hub / github.com/gitify-app/gitify / fetchNotificationDetailsForList

Function fetchNotificationDetailsForList

src/renderer/utils/api/client.ts:286–364  ·  view source on GitHub ↗
(
  notifications: GitifyNotification[],
)

Source from the content-addressed store, hash-verified

284 * making the most efficient use of the available GitHub API quota limits.
285 */
286export async function fetchNotificationDetailsForList(
287 notifications: GitifyNotification[],
288): Promise<
289 Map<GitifyNotification, FetchMergedDetailsTemplateQuery['repository']>
290> {
291 const results = new Map<
292 GitifyNotification,
293 FetchMergedDetailsTemplateQuery['repository']
294 >();
295
296 if (!notifications.length) {
297 return results;
298 }
299
300 // Build merged query using the builder
301 const builder = new MergeQueryBuilder();
302 const aliasToNotification = new Map<string, GitifyNotification>();
303 let hasSupportedNotification = false;
304
305 for (const notification of notifications) {
306 const handler = createNotificationHandler(notification);
307 if (!handler.supportsMergedQueryEnrichment) {
308 continue;
309 }
310
311 hasSupportedNotification = true;
312
313 const alias = builder.addNode({
314 owner: notification.repository.owner.login,
315 name: notification.repository.name,
316 number: getNumberFromUrl(notification.subject.url!),
317 isDiscussionNotification: notification.subject.type === 'Discussion',
318 isIssueNotification: notification.subject.type === 'Issue',
319 isPullRequestNotification: notification.subject.type === 'PullRequest',
320 });
321
322 aliasToNotification.set(alias, notification);
323 }
324
325 if (!hasSupportedNotification) {
326 return results;
327 }
328
329 builder.setSharedVariables({
330 includeIsAnswered: isAnsweredDiscussionFeatureSupported(
331 notifications[0].account,
332 ),
333 firstClosingIssues: Constants.GRAPHQL_ARGS.FIRST_CLOSING_ISSUES,
334 firstLabels: Constants.GRAPHQL_ARGS.FIRST_LABELS,
335 lastComments: Constants.GRAPHQL_ARGS.LAST_COMMENTS,
336 lastThreadedComments: Constants.GRAPHQL_ARGS.LAST_THREADED_COMMENTS,
337 lastReplies: Constants.GRAPHQL_ARGS.LAST_REPLIES,
338 lastReviews: Constants.GRAPHQL_ARGS.LAST_REVIEWS,
339 });
340
341 const query = builder.getGraphQLQuery();
342 const variables = builder.getGraphQLVariables();
343

Callers 2

client.test.tsFile · 0.90

Calls 8

addNodeMethod · 0.95
setSharedVariablesMethod · 0.95
getGraphQLQueryMethod · 0.95
getGraphQLVariablesMethod · 0.95
getNumberFromUrlFunction · 0.90

Tested by

no test coverage detected