From 72f36a91f18c98710a7d382c0e443af28f7abb39 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Mon, 5 Jan 2026 08:52:06 -0500 Subject: [PATCH] refactor: use handler for NotificationHeader formatting Signed-off-by: Adam Setch --- .../components/notifications/NotificationHeader.tsx | 6 +++--- src/renderer/utils/notifications/handlers/default.ts | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/renderer/components/notifications/NotificationHeader.tsx b/src/renderer/components/notifications/NotificationHeader.tsx index f2941f70e..b5d58962d 100644 --- a/src/renderer/components/notifications/NotificationHeader.tsx +++ b/src/renderer/components/notifications/NotificationHeader.tsx @@ -7,6 +7,7 @@ import { type GitifyNotification, Opacity, Size } from '../../types'; import { cn } from '../../utils/cn'; import { openRepository } from '../../utils/links'; import { isGroupByDate } from '../../utils/notifications/group'; +import { createNotificationHandler } from '../../utils/notifications/handlers'; import { AvatarWithFallback } from '../avatars/AvatarWithFallback'; interface NotificationHeaderProps { @@ -20,9 +21,8 @@ export const NotificationHeader: FC = ({ const repoSlug = notification.repository.fullName; - const notificationNumber = notification.subject?.number - ? `#${notification.subject.number}` - : ''; + const handler = createNotificationHandler(notification); + const notificationNumber = handler.formattedNotificationNumber(notification); return ( isGroupByDate(settings) && ( diff --git a/src/renderer/utils/notifications/handlers/default.ts b/src/renderer/utils/notifications/handlers/default.ts index 1cb615390..a4750a3e1 100644 --- a/src/renderer/utils/notifications/handlers/default.ts +++ b/src/renderer/utils/notifications/handlers/default.ts @@ -49,10 +49,12 @@ export class DefaultHandler implements NotificationTypeHandler { formattedNotificationTitle(notification: GitifyNotification): string { let title = notification.subject.title; + const number = this.formattedNotificationNumber(notification); - if (notification.subject?.number) { - title = `${title} [${this.formattedNotificationNumber(notification)}]`; + if (number.length > 0) { + title = `${title} [${number}]`; } + return title; }