[Glitch] Change label of grouped favourite notification on private mentions

Port a4560d9278 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
pull/2921/head
Claire 2024-12-11 11:25:51 +01:00
parent 37070a7881
commit 9e7a7c713f
1 changed files with 33 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
} }