From f0dd8ca0610f3aa7b2f1380dbd94ab019fa14379 Mon Sep 17 00:00:00 2001 From: Jayesh Date: Tue, 17 Aug 2021 15:24:53 +0000 Subject: [PATCH] feat: get new_content in getLocalizedBody --- lib/src/event.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/src/event.dart b/lib/src/event.dart index ba2e2894..ec5b6ae6 100644 --- a/lib/src/event.dart +++ b/lib/src/event.dart @@ -563,8 +563,12 @@ class Event extends MatrixEvent { /// Returns a localized String representation of this event. For a /// room list you may find [withSenderNamePrefix] useful. Set [hideReply] to /// crop all lines starting with '>'. - String getLocalizedBody(MatrixLocalizations i18n, - {bool withSenderNamePrefix = false, bool hideReply = false}) { + String getLocalizedBody( + MatrixLocalizations i18n, { + bool withSenderNamePrefix = false, + bool hideReply = false, + bool hideEdit = false, + }) { if (redacted) { return i18n.removedBy(redactedBecause.sender.calcDisplayname()); } @@ -573,12 +577,15 @@ class Event extends MatrixEvent { if (callback != null) { localizedBody = callback(this, i18n); } - // Hide reply fallback if (hideReply) { localizedBody = localizedBody.replaceFirst( RegExp(r'^>( \*)? <[^>]+>[^\n\r]+\r?\n(> [^\n]*\r?\n)*\r?\n'), ''); } + // Hide edit fallback + if (hideEdit && relationshipType == RelationshipTypes.edit) { + localizedBody = content['m.new_content']['body'] ?? localizedBody; + } // Add the sender name prefix if (withSenderNamePrefix &&