From 84dd3f4083659bc2eceebcce454300220c69e2b5 Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Tue, 8 Mar 2022 09:44:33 +0000 Subject: [PATCH 1/2] Do not render redacted messages --- Riot/Utils/EventFormatter.m | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Riot/Utils/EventFormatter.m b/Riot/Utils/EventFormatter.m index f4d0a2dbd..046df42e6 100644 --- a/Riot/Utils/EventFormatter.m +++ b/Riot/Utils/EventFormatter.m @@ -69,11 +69,7 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm"; // 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.eventTypesFilterForMessages containsObject:event.type] - && !event.isEditEvent - ) + if ( !string && [self shouldBeVisibleEvent:event]) { MXLogError(@"[EventFormatter]: Cannot format string for displayable event: %@, type: %@, msgtype: %@, has room state: %d, members: %lu, error: %lu", event.eventId, @@ -89,6 +85,12 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm"; return string; } +- (BOOL)shouldBeVisibleEvent:(MXEvent *)event { + return [self.eventTypesFilterForMessages containsObject:event.type] + && !event.isEditEvent + && !event.isRedactedEvent; +} + // The attributed string can fail to be created for a number of reasons, and the size of the function (as well as super's implementation) makes // it impossible to catch all the `return nil` and failure states. // To make catching of missing strings reliable (and not place that burden on callers), we use private `unsafeAttributedStringFromEvent` method From 0bca33c0a822b86e80e8330c527cfdbb89d30d5b Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Tue, 8 Mar 2022 11:02:48 +0000 Subject: [PATCH 2/2] Update name --- Riot/Utils/EventFormatter.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Riot/Utils/EventFormatter.m b/Riot/Utils/EventFormatter.m index 046df42e6..e1dbffbb6 100644 --- a/Riot/Utils/EventFormatter.m +++ b/Riot/Utils/EventFormatter.m @@ -69,7 +69,7 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm"; // 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 shouldBeVisibleEvent:event]) + if (!string && [self shouldDisplayEvent:event]) { MXLogError(@"[EventFormatter]: Cannot format string for displayable event: %@, type: %@, msgtype: %@, has room state: %d, members: %lu, error: %lu", event.eventId, @@ -85,7 +85,7 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm"; return string; } -- (BOOL)shouldBeVisibleEvent:(MXEvent *)event { +- (BOOL)shouldDisplayEvent:(MXEvent *)event { return [self.eventTypesFilterForMessages containsObject:event.type] && !event.isEditEvent && !event.isRedactedEvent;