From e10cb03b45360dbc864873bee325999bbe464444 Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Wed, 9 Mar 2022 13:32:35 +0000 Subject: [PATCH 1/2] Only render missing messages for m.room.message types --- Riot/Utils/EventFormatter.m | 21 ++++++++++++--------- changelog.d/5783.bugfix | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 changelog.d/5783.bugfix diff --git a/Riot/Utils/EventFormatter.m b/Riot/Utils/EventFormatter.m index e1dbffbb6..9f7a39a6e 100644 --- a/Riot/Utils/EventFormatter.m +++ b/Riot/Utils/EventFormatter.m @@ -66,27 +66,30 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm"; - (NSAttributedString *)attributedStringFromEvent:(MXEvent *)event withRoomState:(MXRoomState *)roomState error:(MXKEventFormatterError *)error { NSAttributedString *string = [self unsafeAttributedStringFromEvent:event withRoomState:roomState error:error]; - - // If we cannot create attributed string, but the message is nevertheless meant for display (e.g. not an edit event), show generic error - // instead of a missing message on a timeline. - if (!string && [self shouldDisplayEvent:event]) + if (!string) { - MXLogError(@"[EventFormatter]: Cannot format string for displayable event: %@, type: %@, msgtype: %@, has room state: %d, members: %lu, error: %lu", + MXLogDebug(@"[EventFormatter]: No attributed string for event: %@, type: %@, msgtype: %@, has room state: %d, members: %lu, error: %lu", event.eventId, event.type, event.content[@"msgtype"], roomState != nil, roomState.membersCount.members, *error); - string = [[NSAttributedString alloc] initWithString:[VectorL10n noticeErrorUnformattableEvent] attributes:@{ - NSFontAttributeName: [self encryptedMessagesTextFont] - }]; + + // If we cannot create attributed string, but the message is nevertheless meant for display, show generic error + // instead of a missing message on a timeline. + if (event.eventType == MXEventTypeRoomMessage) { + MXLogError(@"[EventFormatter]: Missing attributed string for message event: %@", event.eventId); + string = [[NSAttributedString alloc] initWithString:[VectorL10n noticeErrorUnformattableEvent] attributes:@{ + NSFontAttributeName: [self encryptedMessagesTextFont] + }]; + } } return string; } - (BOOL)shouldDisplayEvent:(MXEvent *)event { - return [self.eventTypesFilterForMessages containsObject:event.type] + return event.eventType == MXEventTypeRoomMessage && !event.isEditEvent && !event.isRedactedEvent; } diff --git a/changelog.d/5783.bugfix b/changelog.d/5783.bugfix new file mode 100644 index 000000000..002db0405 --- /dev/null +++ b/changelog.d/5783.bugfix @@ -0,0 +1 @@ +Room: Only render missing messages for m.room.message types From e3ebb76181d98582f56b33d83748168ac382607b Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Wed, 9 Mar 2022 13:34:18 +0000 Subject: [PATCH 2/2] Small change --- Riot/Utils/EventFormatter.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Riot/Utils/EventFormatter.m b/Riot/Utils/EventFormatter.m index 9f7a39a6e..64bd0f5d5 100644 --- a/Riot/Utils/EventFormatter.m +++ b/Riot/Utils/EventFormatter.m @@ -78,7 +78,7 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm"; // If we cannot create attributed string, but the message is nevertheless meant for display, show generic error // instead of a missing message on a timeline. - if (event.eventType == MXEventTypeRoomMessage) { + if ([self shouldDisplayEvent:event]) { MXLogError(@"[EventFormatter]: Missing attributed string for message event: %@", event.eventId); string = [[NSAttributedString alloc] initWithString:[VectorL10n noticeErrorUnformattableEvent] attributes:@{ NSFontAttributeName: [self encryptedMessagesTextFont]