Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
MXKEventFormatter: Emotes which contain a single emoji are expanded t…
Browse files Browse the repository at this point in the history
…o be enormous (element-hq/element-ios#1558)

Make sure the emote prefix always uses default font and color.
  • Loading branch information
manuroe committed Feb 22, 2018
1 parent 9fa08a4 commit 9435018
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions MatrixKit/Utils/MXKEventFormatter.m
Original file line number Diff line number Diff line change
Expand Up @@ -835,11 +835,7 @@ - (NSAttributedString *)attributedStringFromEvent:(MXEvent *)event withRoomState

if (body)
{
if ([msgtype isEqualToString:kMXMessageTypeEmote])
{
body = [NSString stringWithFormat:@"* %@ %@", senderDisplayName, body];
}
else if ([msgtype isEqualToString:kMXMessageTypeImage])
if ([msgtype isEqualToString:kMXMessageTypeImage])
{
body = body? body : [NSBundle mxk_localizedStringForKey:@"notice_image_attachment"];
// Check attachment validity
Expand Down Expand Up @@ -923,6 +919,23 @@ - (NSAttributedString *)attributedStringFromEvent:(MXEvent *)event withRoomState
// Build the attributed string with the right font and color for the event
attributedDisplayText = [self renderString:body forEvent:event];
}

// Build the full emote string after the body message formatting
if ([msgtype isEqualToString:kMXMessageTypeEmote])
{
// Always use default font and color for the emote prefix
NSString *emotePrefix = [NSString stringWithFormat:@"* %@ ", senderDisplayName];
NSMutableAttributedString *newAttributedDisplayText =
[[NSMutableAttributedString alloc] initWithString:emotePrefix
attributes:@{
NSForegroundColorAttributeName: [self textColorForEvent:event],
NSFontAttributeName: _defaultTextFont
}];

// Then, append the styled body message
[newAttributedDisplayText appendAttributedString:attributedDisplayText];
attributedDisplayText = newAttributedDisplayText;
}
}
}
break;
Expand Down

0 comments on commit 9435018

Please sign in to comment.