Skip to content

Commit a1241bd

Browse files
committed
feat: notification number relo for groupByDate mode
Signed-off-by: Adam Setch <[email protected]>
1 parent c3a4b3c commit a1241bd

File tree

5 files changed

+50
-10
lines changed

5 files changed

+50
-10
lines changed

src/renderer/components/notifications/NotificationHeader.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { type FC, type MouseEvent, useContext } from 'react';
33
import { Avatar, Stack, Tooltip } from '@primer/react';
44

55
import { AppContext } from '../../context/App';
6-
import { Size } from '../../types';
6+
import { GroupBy, Opacity, Size } from '../../types';
77
import type { Notification } from '../../typesGitHub';
8+
import { cn } from '../../utils/cn';
89
import { openRepository } from '../../utils/links';
910

1011
interface INotificationHeader {
@@ -19,7 +20,11 @@ export const NotificationHeader: FC<INotificationHeader> = ({
1920
const repoAvatarUrl = notification.repository.owner.avatar_url;
2021
const repoSlug = notification.repository.full_name;
2122

22-
const groupByDate = settings.groupBy === 'DATE';
23+
const notificationNumber = notification.subject?.number
24+
? `#${notification.subject.number}`
25+
: '';
26+
27+
const groupByDate = settings.groupBy === GroupBy.DATE;
2328

2429
return (
2530
groupByDate && (
@@ -35,6 +40,15 @@ export const NotificationHeader: FC<INotificationHeader> = ({
3540
<Stack direction="horizontal" align="center" gap="condensed">
3641
<Avatar src={repoAvatarUrl} size={Size.SMALL} />
3742
<span className="text-xs font-medium">{repoSlug}</span>
43+
<span
44+
className={cn(
45+
'text-xxs',
46+
Opacity.READ,
47+
!settings.showNumber && 'hidden',
48+
)}
49+
>
50+
{notificationNumber}
51+
</span>
3852
</Stack>
3953
</div>
4054
</Tooltip>

src/renderer/components/notifications/NotificationRow.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { BellSlashIcon, CheckIcon, ReadIcon } from '@primer/octicons-react';
1010
import { IconButton, Tooltip } from '@primer/react';
1111

1212
import { AppContext } from '../../context/App';
13-
import { Opacity, Size } from '../../types';
13+
import { GroupBy, Opacity, Size } from '../../types';
1414
import type { Notification } from '../../typesGitHub';
1515
import { cn } from '../../utils/cn';
1616
import { isMarkAsDoneFeatureSupported } from '../../utils/features';
@@ -84,6 +84,8 @@ export const NotificationRow: FC<INotificationRow> = ({
8484
const notificationTitle =
8585
`${notification.subject.title} ${notificationNumber}`.trim();
8686

87+
const groupByDate = settings.groupBy === GroupBy.DATE;
88+
8789
return (
8890
<div
8991
id={notification.id}
@@ -116,7 +118,7 @@ export const NotificationRow: FC<INotificationRow> = ({
116118
className={cn(
117119
'text-xxs',
118120
Opacity.READ,
119-
!settings.showNumber && 'hidden',
121+
(groupByDate || !settings.showNumber) && 'hidden',
120122
)}
121123
>
122124
{notificationNumber}

src/renderer/components/notifications/__snapshots__/AccountNotifications.test.tsx.snap

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/components/notifications/__snapshots__/NotificationHeader.test.tsx.snap

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/components/notifications/__snapshots__/NotificationRow.test.tsx.snap

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)