From 49b4f87534133ac065a6dd1d0afc61224d8b730a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Tue, 29 Oct 2024 17:05:21 +0100 Subject: [PATCH] pl-hooks: remove duplicate code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- packages/pl-hooks/lib/importer.ts | 8 ++++---- packages/pl-hooks/lib/normalizers/notification.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/pl-hooks/lib/importer.ts b/packages/pl-hooks/lib/importer.ts index 845735798..ec9d94b3a 100644 --- a/packages/pl-hooks/lib/importer.ts +++ b/packages/pl-hooks/lib/importer.ts @@ -1,6 +1,6 @@ import { queryClient } from 'pl-hooks/contexts/query-client'; -import { type DeduplicatedNotification, type NormalizedNotification, normalizeNotification } from './normalizers/notification'; +import { type DeduplicatedNotification, getNotificationStatus, type NormalizedNotification, normalizeNotification } from './normalizers/notification'; import { type NormalizedStatus, normalizeStatus } from './normalizers/status'; import type { @@ -70,9 +70,9 @@ const importEntities = (entities: { processAccount(notification.account); if (notification.type === 'move') processAccount(notification.target); - if (['mention', 'status', 'reblog', 'favourite', 'poll', 'update', 'emoji_reaction', 'event_reminder', 'participation_accepted', 'participation_request'].includes(notification.type)) { - // @ts-ignore - processStatus(notification.status); + const status = getNotificationStatus(notification); + if (status) { + processStatus(status); } }; diff --git a/packages/pl-hooks/lib/normalizers/notification.ts b/packages/pl-hooks/lib/normalizers/notification.ts index 3299778e7..d89cc2b90 100644 --- a/packages/pl-hooks/lib/normalizers/notification.ts +++ b/packages/pl-hooks/lib/normalizers/notification.ts @@ -126,4 +126,4 @@ const normalizeNotification = (notification: BaseNotification | DeduplicatedNoti type NormalizedNotification = ReturnType; -export { deduplicateNotifications, normalizeNotification, type DeduplicatedNotification, type NormalizedNotification }; +export { deduplicateNotifications, getNotificationStatus, normalizeNotification, type DeduplicatedNotification, type NormalizedNotification };