feat: get new_content in getLocalizedBody

This commit is contained in:
Jayesh 2021-08-17 15:24:53 +00:00 committed by Nicolas Werner
parent 98b0bd4322
commit f0dd8ca061
1 changed files with 10 additions and 3 deletions

View File

@ -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 &&