feat: get new_content in getLocalizedBody
This commit is contained in:
parent
98b0bd4322
commit
f0dd8ca061
|
|
@ -563,8 +563,12 @@ class Event extends MatrixEvent {
|
||||||
/// Returns a localized String representation of this event. For a
|
/// Returns a localized String representation of this event. For a
|
||||||
/// room list you may find [withSenderNamePrefix] useful. Set [hideReply] to
|
/// room list you may find [withSenderNamePrefix] useful. Set [hideReply] to
|
||||||
/// crop all lines starting with '>'.
|
/// crop all lines starting with '>'.
|
||||||
String getLocalizedBody(MatrixLocalizations i18n,
|
String getLocalizedBody(
|
||||||
{bool withSenderNamePrefix = false, bool hideReply = false}) {
|
MatrixLocalizations i18n, {
|
||||||
|
bool withSenderNamePrefix = false,
|
||||||
|
bool hideReply = false,
|
||||||
|
bool hideEdit = false,
|
||||||
|
}) {
|
||||||
if (redacted) {
|
if (redacted) {
|
||||||
return i18n.removedBy(redactedBecause.sender.calcDisplayname());
|
return i18n.removedBy(redactedBecause.sender.calcDisplayname());
|
||||||
}
|
}
|
||||||
|
|
@ -573,12 +577,15 @@ class Event extends MatrixEvent {
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
localizedBody = callback(this, i18n);
|
localizedBody = callback(this, i18n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide reply fallback
|
// Hide reply fallback
|
||||||
if (hideReply) {
|
if (hideReply) {
|
||||||
localizedBody = localizedBody.replaceFirst(
|
localizedBody = localizedBody.replaceFirst(
|
||||||
RegExp(r'^>( \*)? <[^>]+>[^\n\r]+\r?\n(> [^\n]*\r?\n)*\r?\n'), '');
|
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
|
// Add the sender name prefix
|
||||||
if (withSenderNamePrefix &&
|
if (withSenderNamePrefix &&
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue