Skip to content

Commit a310706

Browse files
committed
feat: format display attributes on GitifyNotification
Signed-off-by: Adam Setch <[email protected]>
1 parent 8c7f936 commit a310706

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/renderer/utils/notifications/formatters.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,22 @@ export function formatNotificationType(
4949
]);
5050
}
5151

52+
/**
53+
* Return the formatted (issue, pull request, discussion) number for this notification.
54+
*/
55+
export function formatGitHubNumber(num: number): string {
56+
return `#${num}`;
57+
}
58+
5259
/**
5360
* Return the formatted notification number for this notification.
5461
*/
5562
export function formatNotificationNumber(
5663
notification: GitifyNotification,
5764
): string {
58-
return notification.subject?.number ? `#${notification.subject.number}` : '';
65+
return notification.subject?.number
66+
? formatGitHubNumber(notification.subject.number)
67+
: '';
5968
}
6069

6170
/**

src/renderer/utils/notifications/handlers/pullRequest.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import type {
2323
PullRequestDetailsFragment,
2424
PullRequestReviewFieldsFragment,
2525
} from '../../api/graphql/generated/graphql';
26+
import { formatGitHubNumber } from '../formatters';
2627
import { DefaultHandler, defaultHandler } from './default';
2728
import { getNotificationAuthor } from './utils';
2829

@@ -60,8 +61,8 @@ class PullRequestHandler extends DefaultHandler {
6061
reviews: reviews,
6162
commentCount: pr.comments.totalCount,
6263
labels: pr.labels?.nodes.map((label) => label.name) ?? [],
63-
linkedIssues: pr.closingIssuesReferences?.nodes.map(
64-
(issue) => `#${issue.number}`,
64+
linkedIssues: pr.closingIssuesReferences?.nodes.map((issue) =>
65+
formatGitHubNumber(issue.number),
6566
),
6667
milestone: pr.milestone,
6768
htmlUrl: prComment?.url ?? pr.url,

src/renderer/utils/notifications/notifications.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ function getNotifications(state: GitifyState) {
6767
/**
6868
* Get all notifications for all accounts.
6969
*
70+
* Notifications follow these stages:
71+
* - Fetch / retrieval
72+
* - Transform
73+
* - Base filtering
74+
* - Enrichment
75+
* - Detailed filtering
76+
* - Formatting
77+
* - Ordering
78+
*
7079
* @param state - The Gitify state.
7180
* @returns A promise that resolves to an array of account notifications.
7281
*/

0 commit comments

Comments
 (0)