Skip to content

Commit

Permalink
feat: show notification number for issues, prs, discussions
Browse files Browse the repository at this point in the history
  • Loading branch information
setchy committed Jun 19, 2024
1 parent 0027d84 commit 28c6bf8
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/components/NotificationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,18 @@ export const NotificationRow: FC<INotificationRow> = ({
? `${notification.subject.user.login} updated ${updatedAt}`
: `Updated ${updatedAt}`;

const notificationTitle = formatForDisplay([
const notificationType = formatForDisplay([
notification.subject.state,
notification.subject.type,
]);

const notificationNumber = notification.subject?.number
? `#${notification.subject.number}`
: '';

const notificationTitle =
`${notification.subject.title} ${notificationNumber}`.trim();

const commentsPillDescription = `${notification.subject.comments} ${
notification.subject.comments > 1 ? 'comments' : 'comment'
}`;
Expand All @@ -112,7 +119,7 @@ export const NotificationRow: FC<INotificationRow> = ({
>
<div
className={cn('mr-3 flex w-5 items-center justify-center', iconColor)}
title={notificationTitle}
title={notificationType}
>
<NotificationIcon size={16} aria-label={notification.subject.type} />
</div>
Expand All @@ -124,9 +131,10 @@ export const NotificationRow: FC<INotificationRow> = ({
<div
className="mb-1 cursor-pointer truncate text-sm"
role="main"
title={notification.subject.title}
title={notificationTitle}
>
{notification.subject.title}
<span className="text-xs"> {notificationNumber}</span>
</div>

<div className="flex flex-wrap items-center gap-1 text-xs capitalize">
Expand Down
120 changes: 120 additions & 0 deletions src/components/__snapshots__/NotificationRow.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/typesGitHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ interface GitHubSubject {

// This is not in the GitHub API, but we add it to the type to make it easier to work with
export interface GitifySubject {
number?: number;
state?: StateType;
user?: SubjectUser;
reviews?: GitifyPullRequestReview[];
Expand Down Expand Up @@ -494,6 +495,7 @@ export interface GraphQLSearch<T> {
}

export interface Discussion {
number: number;
title: string;
stateReason: DiscussionStateType;
isAnswered: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/utils/api/__mocks__/response-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ export const mockGraphQLResponse: GraphQLSearch<Discussion> = {
search: {
nodes: [
{
number: 123,
title: '1.16.0',
isAnswered: false,
stateReason: 'OPEN',
Expand Down
1 change: 1 addition & 0 deletions src/utils/api/graphql/discussions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const QUERY_SEARCH_DISCUSSIONS = gql`
search(query: $queryStatement, type: DISCUSSION, first: $firstDiscussions) {
nodes {
... on Discussion {
number
title
stateReason
isAnswered
Expand Down
Loading

0 comments on commit 28c6bf8

Please sign in to comment.