Repository navigation
fix(chat): render photo captions like text messages - #1839
Merged
Merged
Conversation
A photo's caption was drawn as a text body but never read as one: linkableText() and linkPreview() returned null for Media, so no link card was classified and a sender-built preview was ignored. Both now read the caption (a photo reply reads its photo's caption, not the reply's own text), and the photo bubble draws the existing web link card under the caption, widening to the bubble width once it has a preview. Flipcash cash and message cards are not drawn for captions: they split a bubble into rows, which a photo has none of.
Copy is offered for a photo, or a reply carrying one, whose caption is non-empty; edit stays off since it would have to re-seal the image. ChatListItem.plainText follows the caption, and splitAroundLinkCard leaves a photo alone for any non-web card. A redacted caption is hidden as a redacted text body is.
A caption now gets the card a text message with the same text gets, including a Flipcash cash or message card, which draws under the caption in the slot the web card uses and takes the same claim and tap handling. A cash link ahead of a web link no longer leaves the caption with no card. A caption that is only its link is the card alone with no caption row, and an emoji-only caption is drawn large with no bubble, as in a text message.
Drop the wrapper shape and padding that drew a Flipcash card inside the caption bubble. A Flipcash card now draws only when the caption is just the link, through BareLinkCard as in text. With words around it, text splits the prose into rows around the card, which a photo row cannot do without new UI, so the caption draws as text with no card.
Senders never attach a preview to a caption (the text goes out as its own message) and the mapper drops caption link previews, so a caption's web card was never resolved and the branch was unreachable. Remove the WebLinkCard/BareWebCard drawing from the photo bubble, return the helpers widened only for it to private, and drop its tests. A web card on a photo row is now dropped when the row is split.
A photo caption with words around a group invite, profile or tip link showed the raw link and no card. It now splits as the same text message does: the caption text with the link removed, the card under it, and any text after the link in a bubble below the card. Cash and token links still draw as caption text unless they are the whole caption.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A photo caption doesn't render like the same text sent as a message. A text message with a group, profile or tip link draws the Flipcash card, an emoji-only one draws jumbo emoji, and long-press offers Copy. A caption got none of that.
ChatPhotoBubbledraws the caption with the text message's components:BareLinkCardfor a Flipcash link, placed withposition.withPhotoAbove(), andJumboEmojifor an emoji-only caption.BareLinkCard,JumboEmojiandCASH_CARD_WIDTH_FRACTIONgo from private to internal inMessageBubble.kt.splitAroundLinkCardkeeps a group invite, user or message card on a photo row. A caption that is only the link draws the card under the photo. With words around it,LinkCard.captionRowsAroundsplits the caption with the samemarginsInandsaysSomethingrules the text path uses: the words with the link removed, then the card, then any words after the link.LinkCard.Webon a photo row is dropped before resolution. Neither app attaches a link preview to a caption: when the composer has one, the photo and the text go out as two messages, and that doesn't change here.Tests are in
MediaCaptionCardTest,MediaCaptionMentionTestandSplitAroundLinkCardTest.iOS counterpart: code-payments/code-ios-app#1124.