@@ -1326,7 +1326,7 @@ func PresentRemoteConversationAsBigTeamChannelRow(ctx context.Context, rc types.
13261326 return res
13271327}
13281328
1329- func PresentRemoteConversation (ctx context.Context , g * globals.Context , rc types.RemoteConversation ) (res chat1.UnverifiedInboxUIItem ) {
1329+ func PresentRemoteConversation (ctx context.Context , g * globals.Context , uid gregor1. UID , rc types.RemoteConversation ) (res chat1.UnverifiedInboxUIItem ) {
13301330 var tlfName string
13311331 rawConv := rc .Conv
13321332 latest , err := PickLatestMessageSummary (rawConv , nil )
@@ -1360,9 +1360,10 @@ func PresentRemoteConversation(ctx context.Context, g *globals.Context, rc types
13601360 chat1 .NewConversationCommandGroupsWithBuiltin (g .CommandsSource .GetBuiltinCommandType (ctx , rc ))
13611361 if rc .LocalMetadata != nil {
13621362 res .LocalMetadata = & chat1.UnverifiedInboxUIItemMetadata {
1363- ChannelName : rc .LocalMetadata .TopicName ,
1364- Headline : rc .LocalMetadata .Headline ,
1365- HeadlineDecorated : DecorateWithLinks (ctx , EscapeForDecorate (ctx , rc .LocalMetadata .Headline )),
1363+ ChannelName : rc .LocalMetadata .TopicName ,
1364+ Headline : rc .LocalMetadata .Headline ,
1365+ HeadlineDecorated : DecorateWithLinks (ctx , PresentDecoratedSnippet (ctx , g , rc .LocalMetadata .Headline , uid , rc .GetConvID (),
1366+ chat1 .MessageType_HEADLINE , rc .LocalMetadata .HeadlineEmojis )),
13661367 Snippet : rc .LocalMetadata .Snippet ,
13671368 SnippetDecoration : rc .LocalMetadata .SnippetDecoration ,
13681369 WriterNames : rc .LocalMetadata .WriterNames ,
@@ -1376,9 +1377,10 @@ func PresentRemoteConversation(ctx context.Context, g *globals.Context, rc types
13761377 return res
13771378}
13781379
1379- func PresentRemoteConversations (ctx context.Context , g * globals.Context , rcs []types.RemoteConversation ) (res []chat1.UnverifiedInboxUIItem ) {
1380+ func PresentRemoteConversations (ctx context.Context , g * globals.Context , uid gregor1.UID , rcs []types.RemoteConversation ) (res []chat1.UnverifiedInboxUIItem ) {
1381+ res = make ([]chat1.UnverifiedInboxUIItem , 0 , len (rcs ))
13801382 for _ , rc := range rcs {
1381- res = append (res , PresentRemoteConversation (ctx , g , rc ))
1383+ res = append (res , PresentRemoteConversation (ctx , g , uid , rc ))
13821384 }
13831385 return res
13841386}
@@ -1404,16 +1406,17 @@ func PresentRemoteConversationAsSearchHit(conv types.RemoteConversation, usernam
14041406}
14051407
14061408func PresentRemoteConversationsAsSearchHits (convs []types.RemoteConversation , username string ) (res []chat1.UIChatSearchConvHit ) {
1409+ res = make ([]chat1.UIChatSearchConvHit , 0 , len (convs ))
14071410 for _ , c := range convs {
14081411 res = append (res , PresentRemoteConversationAsSearchHit (c , username ))
14091412 }
14101413 return res
14111414}
14121415
1413- func PresentConversationErrorLocal (ctx context.Context , g * globals.Context , rawConv chat1.ConversationErrorLocal ) (res chat1.InboxUIItemError ) {
1416+ func PresentConversationErrorLocal (ctx context.Context , g * globals.Context , uid gregor1. UID , rawConv chat1.ConversationErrorLocal ) (res chat1.InboxUIItemError ) {
14141417 res .Message = rawConv .Message
14151418 res .RekeyInfo = rawConv .RekeyInfo
1416- res .RemoteConv = PresentRemoteConversation (ctx , g , types.RemoteConversation {
1419+ res .RemoteConv = PresentRemoteConversation (ctx , g , uid , types.RemoteConversation {
14171420 Conv : rawConv .RemoteConv ,
14181421 ConvIDStr : rawConv .RemoteConv .GetConvID ().ConvIDStr (),
14191422 })
@@ -1433,6 +1436,7 @@ func getParticipantType(username string) chat1.UIParticipantType {
14331436}
14341437
14351438func PresentConversationParticipantsLocal (ctx context.Context , rawParticipants []chat1.ConversationLocalParticipant ) (participants []chat1.UIParticipant ) {
1439+ participants = make ([]chat1.UIParticipant , 0 , len (rawParticipants ))
14361440 for _ , p := range rawParticipants {
14371441 participantType := getParticipantType (p .Username )
14381442 participants = append (participants , chat1.UIParticipant {
@@ -1465,7 +1469,8 @@ func PresentConversationLocal(ctx context.Context, g *globals.Context, uid grego
14651469 GetConvSnippet (ctx , g , uid , rawConv , g .GetEnv ().GetUsername ().String ())
14661470 res .Channel = rawConv .Info .TopicName
14671471 res .Headline = rawConv .Info .Headline
1468- res .HeadlineDecorated = DecorateWithLinks (ctx , EscapeForDecorate (ctx , rawConv .Info .Headline ))
1472+ res .HeadlineDecorated = DecorateWithLinks (ctx , PresentDecoratedSnippet (ctx , g , rawConv .Info .Headline , uid ,
1473+ rawConv .GetConvID (), chat1 .MessageType_HEADLINE , rawConv .Info .HeadlineEmojis ))
14691474 res .ResetParticipants = rawConv .Info .ResetNames
14701475 res .Status = rawConv .Info .Status
14711476 res .MembersType = rawConv .GetMembersType ()
@@ -1805,20 +1810,11 @@ func PresentDecoratedSnippet(ctx context.Context, g *globals.Context, body strin
18051810
18061811func PresentDecoratedPendingTextBody (ctx context.Context , g * globals.Context , uid gregor1.UID ,
18071812 convID chat1.ConversationID , msg chat1.MessagePlaintext ) * string {
1808- msgBody := msg .MessageBody
1809- typ , err := msgBody .MessageType ()
1813+ typ , err := msg .MessageBody .MessageType ()
18101814 if err != nil {
18111815 return nil
18121816 }
1813- var body string
1814- switch typ {
1815- case chat1 .MessageType_TEXT :
1816- body = msgBody .Text ().Body
1817- case chat1 .MessageType_REACTION :
1818- body = msgBody .Reaction ().Body
1819- default :
1820- return nil
1821- }
1817+ body := msg .MessageBody .TextForDecoration ()
18221818 body = PresentDecoratedTextNoMentions (ctx , body )
18231819 body = g .EmojiSource .Decorate (ctx , body , uid , convID , typ , msg .Emojis )
18241820 return & body
@@ -1831,31 +1827,20 @@ func PresentDecoratedTextBody(ctx context.Context, g *globals.Context, uid grego
18311827 if err != nil {
18321828 return nil
18331829 }
1834- var body string
1835- var payments []chat1.TextPayment
1830+ body := msgBody .TextForDecoration ()
1831+ if len (body ) == 0 {
1832+ return nil
1833+ }
18361834 switch typ {
18371835 case chat1 .MessageType_TEXT :
1838- body = msgBody .Text ().Body
1839- payments = msgBody .Text ().Payments
1840- case chat1 .MessageType_FLIP :
1841- body = msgBody .Flip ().Text
1842- case chat1 .MessageType_REQUESTPAYMENT :
1843- body = msgBody .Requestpayment ().Note
1844- case chat1 .MessageType_ATTACHMENT :
1845- body = msgBody .Attachment ().Object .Title
1836+ // Payment decorations
1837+ body = g .StellarSender .DecorateWithPayments (ctx , body , msgBody .Text ().Payments )
18461838 case chat1 .MessageType_SYSTEM :
18471839 body = systemMsgPresentText (ctx , uid , msg )
1848- default :
1849- return nil
18501840 }
18511841 body = PresentDecoratedTextNoMentions (ctx , body )
1852-
1853- // Payment decorations
1854- body = g .StellarSender .DecorateWithPayments (ctx , body , payments )
1855-
18561842 // Emojis
18571843 body = g .EmojiSource .Decorate (ctx , body , uid , convID , typ , msg .Emojis )
1858-
18591844 // Mentions
18601845 body = DecorateWithMentions (ctx , body , msg .AtMentionUsernames , msg .MaybeMentions , msg .ChannelMention ,
18611846 msg .ChannelNameMentions )
0 commit comments