diff --git a/app/javascript/flavours/glitch/features/notifications_v2/components/notification_mention.tsx b/app/javascript/flavours/glitch/features/notifications_v2/components/notification_mention.tsx index 2868cddde0..91e7445ceb 100644 --- a/app/javascript/flavours/glitch/features/notifications_v2/components/notification_mention.tsx +++ b/app/javascript/flavours/glitch/features/notifications_v2/components/notification_mention.tsx @@ -2,26 +2,33 @@ import { FormattedMessage } from 'react-intl'; import AlternateEmailIcon from '@/material-icons/400-24px/alternate_email.svg?react'; import ReplyIcon from '@/material-icons/400-24px/reply-fill.svg?react'; -import type { StatusVisibility } from 'flavours/glitch/api_types/statuses'; +import { me } from 'flavours/glitch/initial_state'; import type { NotificationGroupMention } from 'flavours/glitch/models/notification_group'; +import type { Status } from 'flavours/glitch/models/status'; import { useAppSelector } from 'flavours/glitch/store'; import type { LabelRenderer } from './notification_group_with_status'; import { NotificationWithStatus } from './notification_with_status'; -const labelRenderer: LabelRenderer = (values) => ( +const mentionLabelRenderer: LabelRenderer = () => ( + +); + +const privateMentionLabelRenderer: LabelRenderer = () => ( ); -const privateMentionLabelRenderer: LabelRenderer = (values) => ( +const replyLabelRenderer: LabelRenderer = () => ( + +); + +const privateReplyLabelRenderer: LabelRenderer = () => ( ); @@ -29,27 +36,30 @@ export const NotificationMention: React.FC<{ notification: NotificationGroupMention; unread: boolean; }> = ({ notification, unread }) => { - const statusVisibility = useAppSelector( - (state) => - state.statuses.getIn([ - notification.statusId, - 'visibility', - ]) as StatusVisibility, - ); + const [isDirect, isReply] = useAppSelector((state) => { + const status = state.statuses.get(notification.statusId) as Status; + + return [ + status.get('visibility') === 'direct', + status.get('in_reply_to_account_id') === me, + ] as const; + }); + + let labelRenderer = mentionLabelRenderer; + + if (isReply && isDirect) labelRenderer = privateReplyLabelRenderer; + else if (isReply) labelRenderer = replyLabelRenderer; + else if (isDirect) labelRenderer = privateMentionLabelRenderer; return ( );