From 259199d5c386c243e676d00384b231f3f31001bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 18 Sep 2024 16:55:04 +0200 Subject: [PATCH] pl-fe: fallback for reply subtype MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../notifications/components/notification.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/pl-fe/src/features/notifications/components/notification.tsx b/packages/pl-fe/src/features/notifications/components/notification.tsx index bbeb3f639e..32ec849587 100644 --- a/packages/pl-fe/src/features/notifications/components/notification.tsx +++ b/packages/pl-fe/src/features/notifications/components/notification.tsx @@ -12,7 +12,7 @@ import { HStack, Text, Emoji } from 'pl-fe/components/ui'; import AccountContainer from 'pl-fe/containers/account-container'; import StatusContainer from 'pl-fe/containers/status-container'; import { HotKeys } from 'pl-fe/features/ui/components/hotkeys'; -import { useAppDispatch, useAppSelector, useInstance } from 'pl-fe/hooks'; +import { useAppDispatch, useAppSelector, useInstance, useLoggedIn } from 'pl-fe/hooks'; import { makeGetNotification } from 'pl-fe/selectors'; import { useModalsStore } from 'pl-fe/stores'; import { NotificationType } from 'pl-fe/utils/notification'; @@ -194,6 +194,7 @@ const Notification: React.FC = (props) => { const getNotification = useCallback(makeGetNotification(), []); + const { me } = useLoggedIn(); const { openModal } = useModalsStore(); const notification = useAppSelector((state) => getNotification(state, props.notification)); @@ -289,6 +290,8 @@ const Notification: React.FC = (props) => { } }; + const displayedType = notification.type === 'mention' && (notification.subtype === 'reply' || status.in_reply_to_account_id === me) ? 'reply' : notification.type; + const renderIcon = (): React.ReactNode => { if (type === 'emoji_reaction' && notification.emoji) { return ( @@ -298,10 +301,10 @@ const Notification: React.FC = (props) => { className='h-4 w-4 flex-none' /> ); - } else if (icons[type]) { + } else if (icons[displayedType]) { return ( ); @@ -371,13 +374,13 @@ const Notification: React.FC = (props) => { const targetName = notification.type === 'move' ? notification.target.acct : ''; const message: React.ReactNode = account && typeof account === 'object' - ? buildMessage(intl, type === 'mention' ? notification.subtype || type : type, accounts, targetName, instance.title) + ? buildMessage(intl, displayedType, accounts, targetName, instance.title) : null; const ariaLabel = ( notificationForScreenReader( intl, - intl.formatMessage(messages[type], { + intl.formatMessage(messages[displayedType], { name: account && typeof account === 'object' ? account.acct : '', targetName, }),