From 502fc50939a93ea7198e145e834af75014c5c4a5 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 30 Aug 2024 15:26:56 +0200 Subject: [PATCH] Switch to one line per captioned media attachment --- .../components/embedded_status.tsx | 110 ++++++++---------- 1 file changed, 47 insertions(+), 63 deletions(-) diff --git a/app/javascript/mastodon/features/notifications_v2/components/embedded_status.tsx b/app/javascript/mastodon/features/notifications_v2/components/embedded_status.tsx index 50427f3700..7395e915dc 100644 --- a/app/javascript/mastodon/features/notifications_v2/components/embedded_status.tsx +++ b/app/javascript/mastodon/features/notifications_v2/components/embedded_status.tsx @@ -122,69 +122,11 @@ export const EmbeddedStatus: React.FC<{ statusId: string }> = ({ const mediaAttachments = status.get( 'media_attachments', ) as ImmutableList; - const mediaAttachmentsSize = mediaAttachments.size; - const mediaAttachmentDescription = mediaAttachments.find( + const mediaAttachmentsWithDescription = mediaAttachments.filter( (attachment) => !!attachment.get('description'), - )?.get('description'); - - const mediaAttachmentsList = []; - if (expanded) { - if (poll) { - mediaAttachmentsList.push( -
- - -
, - ); - } - - if (mediaAttachmentDescription) { - mediaAttachmentsList.push( -
- - - {mediaAttachmentDescription} - -
, - ); - - if (mediaAttachmentsSize > 1) { - mediaAttachmentsList.push( -
- - -
, - ); - } - } else if (mediaAttachmentsSize > 0) { - mediaAttachmentsList.push( -
- - -
, - ); - } - } + ); + const uncaptionedMediaCount = + mediaAttachments.size - mediaAttachmentsWithDescription.size; return (
= ({ /> )} - {mediaAttachmentsList} + {expanded && !!poll && ( +
+ + +
+ )} + + {expanded && + mediaAttachmentsWithDescription.size > 0 && + mediaAttachmentsWithDescription.map((attachment) => ( +
+ + {attachment.get('description')} +
+ ))} + + {expanded && uncaptionedMediaCount > 0 && ( +
+ + {mediaAttachmentsWithDescription.size > 0 ? ( + + ) : ( + + )} +
+ )}
); };