diff --git a/lib/components/list_items/chat_list_item.dart b/lib/components/list_items/chat_list_item.dart index 65d4d80..ed82a21 100644 --- a/lib/components/list_items/chat_list_item.dart +++ b/lib/components/list_items/chat_list_item.dart @@ -177,7 +177,7 @@ class ChatListItem extends StatelessWidget { ) : Text( room.lastEvent.getLocalizedBody(context, - withSenderNamePrefix: true, hideQuotes: true), + withSenderNamePrefix: true, hideReply: true), maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( diff --git a/lib/components/matrix.dart b/lib/components/matrix.dart index 2d9e5c8..1dc6223 100644 --- a/lib/components/matrix.dart +++ b/lib/components/matrix.dart @@ -239,7 +239,7 @@ class MatrixState extends State { // Calculate the body final String body = event.getLocalizedBody(context, - withSenderNamePrefix: true, hideQuotes: true); + withSenderNamePrefix: true, hideReply: true); // The person object for the android message style notification final person = Person( diff --git a/lib/components/message_content.dart b/lib/components/message_content.dart index fa3c9d6..82906f5 100644 --- a/lib/components/message_content.dart +++ b/lib/components/message_content.dart @@ -135,7 +135,7 @@ class MessageContent extends StatelessWidget { case MessageTypes.Notice: case MessageTypes.Emote: return LinkText( - text: event.getLocalizedBody(context, hideQuotes: true), + text: event.getLocalizedBody(context, hideReply: true), textStyle: TextStyle( color: textColor, decoration: event.redacted ? TextDecoration.lineThrough : null, diff --git a/lib/components/reply_content.dart b/lib/components/reply_content.dart index 3c63648..306ffa0 100644 --- a/lib/components/reply_content.dart +++ b/lib/components/reply_content.dart @@ -36,7 +36,7 @@ class ReplyContent extends StatelessWidget { ), Text( replyEvent?.getLocalizedBody(context, - withSenderNamePrefix: false, hideQuotes: true) ?? + withSenderNamePrefix: false, hideReply: true) ?? "", overflow: TextOverflow.ellipsis, maxLines: 1, diff --git a/lib/utils/event_extension.dart b/lib/utils/event_extension.dart index dd1e435..865bc01 100644 --- a/lib/utils/event_extension.dart +++ b/lib/utils/event_extension.dart @@ -13,7 +13,7 @@ extension LocalizedBody on Event { }; String getLocalizedBody(BuildContext context, - {bool withSenderNamePrefix = false, bool hideQuotes = false}) { + {bool withSenderNamePrefix = false, bool hideReply = false}) { if (this.redacted) { return I18n.of(context) .removedBy(redactedBecause.sender.calcDisplayname()); @@ -209,11 +209,9 @@ extension LocalizedBody on Event { localizedBody = I18n.of(context).unknownEvent(this.typeKey); } - // Hide quotes - if (hideQuotes) { - List lines = localizedBody.split("\n"); - lines.removeWhere((s) => s.startsWith("> ") || s.isEmpty); - localizedBody = lines.join("\n"); + // Hide reply fallback + if (hideReply) { + localizedBody = localizedBody.replaceFirst(RegExp(r'^>( \*)? <@[a-zA-Z0-9-.=_\/]+:[^>]+>[^\n]+\r?\n(> [^\n]+\r?\n)*\r?\n'), ""); } // Add the sender name prefix