Skip to content

Commit cdd0a09

Browse files
committed
refactor: notification handlers
Signed-off-by: Adam Setch <[email protected]>
1 parent 2c359fd commit cdd0a09

22 files changed

+2979
-2691
lines changed

src/renderer/components/notifications/NotificationRow.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import type { Notification } from '../../typesGitHub';
99
import { cn } from '../../utils/cn';
1010
import { isMarkAsDoneFeatureSupported } from '../../utils/features';
1111
import { formatForDisplay } from '../../utils/helpers';
12-
import {
13-
getNotificationTypeIcon,
14-
getNotificationTypeIconColor,
15-
} from '../../utils/icons';
12+
import { getNotificationTypeIconColor } from '../../utils/icons';
1613
import { openNotification } from '../../utils/links';
14+
import { createNotificationHandler } from '../../utils/notifications/handlers';
1715
import { HoverButton } from '../primitives/HoverButton';
1816
import { HoverGroup } from '../primitives/HoverGroup';
1917
import { NotificationFooter } from './NotificationFooter';
@@ -73,7 +71,9 @@ export const NotificationRow: FC<INotificationRow> = ({
7371
unsubscribeNotification(notification);
7472
};
7573

76-
const NotificationIcon = getNotificationTypeIcon(notification.subject);
74+
const handler = createNotificationHandler(notification);
75+
76+
const NotificationIcon = handler.getIcon(notification.subject);
7777
const iconColor = getNotificationTypeIconColor(notification.subject);
7878

7979
const notificationType = formatForDisplay([

src/renderer/utils/__snapshots__/icons.test.ts.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/utils/helpers.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ import type { Notification } from '../typesGitHub';
1010
import { getHtmlUrl, getLatestDiscussion } from './api/client';
1111
import type { PlatformType } from './auth/types';
1212
import { Constants } from './constants';
13-
import {
14-
getCheckSuiteAttributes,
15-
getClosestDiscussionCommentOrReply,
16-
getWorkflowRunAttributes,
17-
} from './subject';
13+
import { getCheckSuiteAttributes } from './notifications/handlers/checkSuite';
14+
import { getClosestDiscussionCommentOrReply } from './notifications/handlers/discussion';
15+
import { getWorkflowRunAttributes } from './notifications/handlers/workflowRun';
1816

1917
export function getPlatformFromHostname(hostname: string): PlatformType {
2018
return hostname.endsWith(Constants.DEFAULT_AUTH_OPTIONS.hostname)

0 commit comments

Comments
 (0)