Change label of grouped favourite notification on private mentions

This commit is contained in:
Claire 2024-08-30 11:58:35 +02:00
parent 3ddeaca863
commit ec253ddf64
2 changed files with 35 additions and 1 deletions

View file

@ -33,6 +33,34 @@ const labelRenderer: LabelRenderer = (displayedName, total, seeMoreHref) => {
); );
}; };
const privateLabelRenderer: LabelRenderer = (
displayedName,
total,
seeMoreHref,
) => {
if (total === 1)
return (
<FormattedMessage
id='notification.favourite_pm'
defaultMessage='{name} favorited your private mention'
values={{ name: displayedName }}
/>
);
return (
<FormattedMessage
id='notification.favourite_pm.name_and_others_with_link'
defaultMessage='{name} and <a>{count, plural, one {# other} other {# others}}</a> favorited your private mention'
values={{
name: displayedName,
count: total - 1,
a: (chunks) =>
seeMoreHref ? <Link to={seeMoreHref}>{chunks}</Link> : chunks,
}}
/>
);
};
export const NotificationFavourite: React.FC<{ export const NotificationFavourite: React.FC<{
notification: NotificationGroupFavourite; notification: NotificationGroupFavourite;
unread: boolean; unread: boolean;
@ -44,6 +72,10 @@ export const NotificationFavourite: React.FC<{
?.acct, ?.acct,
); );
const isPrivateMention = useAppSelector(
(state) => state.statuses.getIn([statusId, 'visibility']) === 'direct',
);
return ( return (
<NotificationGroupWithStatus <NotificationGroupWithStatus
type='favourite' type='favourite'
@ -53,7 +85,7 @@ export const NotificationFavourite: React.FC<{
statusId={notification.statusId} statusId={notification.statusId}
timestamp={notification.latest_page_notification_at} timestamp={notification.latest_page_notification_at}
count={notification.notifications_count} count={notification.notifications_count}
labelRenderer={labelRenderer} labelRenderer={isPrivateMention ? privateLabelRenderer : labelRenderer}
labelSeeMoreHref={ labelSeeMoreHref={
statusAccount ? `/@${statusAccount}/${statusId}/favourites` : undefined statusAccount ? `/@${statusAccount}/${statusId}/favourites` : undefined
} }

View file

@ -505,6 +505,8 @@
"notification.admin.sign_up.name_and_others": "{name} and {count, plural, one {# other} other {# others}} signed up", "notification.admin.sign_up.name_and_others": "{name} and {count, plural, one {# other} other {# others}} signed up",
"notification.favourite": "{name} favorited your post", "notification.favourite": "{name} favorited your post",
"notification.favourite.name_and_others_with_link": "{name} and <a>{count, plural, one {# other} other {# others}}</a> favorited your post", "notification.favourite.name_and_others_with_link": "{name} and <a>{count, plural, one {# other} other {# others}}</a> favorited your post",
"notification.favourite_pm": "{name} favorited your private mention",
"notification.favourite_pm.name_and_others_with_link": "{name} and <a>{count, plural, one {# other} other {# others}}</a> favorited your private mention",
"notification.follow": "{name} followed you", "notification.follow": "{name} followed you",
"notification.follow.name_and_others": "{name} and {count, plural, one {# other} other {# others}} followed you", "notification.follow.name_and_others": "{name} and {count, plural, one {# other} other {# others}} followed you",
"notification.follow_request": "{name} has requested to follow you", "notification.follow_request": "{name} has requested to follow you",