Merge branch 'soru/reply-fallback' into 'master'
better reply fallback stripping See merge request ChristianPauly/fluffychat-flutter!27
This commit is contained in:
commit
47d5b1a369
|
@ -177,7 +177,7 @@ class ChatListItem extends StatelessWidget {
|
||||||
)
|
)
|
||||||
: Text(
|
: Text(
|
||||||
room.lastEvent.getLocalizedBody(context,
|
room.lastEvent.getLocalizedBody(context,
|
||||||
withSenderNamePrefix: true, hideQuotes: true),
|
withSenderNamePrefix: true, hideReply: true),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
|
|
@ -239,7 +239,7 @@ class MatrixState extends State<Matrix> {
|
||||||
|
|
||||||
// Calculate the body
|
// Calculate the body
|
||||||
final String body = event.getLocalizedBody(context,
|
final String body = event.getLocalizedBody(context,
|
||||||
withSenderNamePrefix: true, hideQuotes: true);
|
withSenderNamePrefix: true, hideReply: true);
|
||||||
|
|
||||||
// The person object for the android message style notification
|
// The person object for the android message style notification
|
||||||
final person = Person(
|
final person = Person(
|
||||||
|
|
|
@ -135,7 +135,7 @@ class MessageContent extends StatelessWidget {
|
||||||
case MessageTypes.Notice:
|
case MessageTypes.Notice:
|
||||||
case MessageTypes.Emote:
|
case MessageTypes.Emote:
|
||||||
return LinkText(
|
return LinkText(
|
||||||
text: event.getLocalizedBody(context, hideQuotes: true),
|
text: event.getLocalizedBody(context, hideReply: true),
|
||||||
textStyle: TextStyle(
|
textStyle: TextStyle(
|
||||||
color: textColor,
|
color: textColor,
|
||||||
decoration: event.redacted ? TextDecoration.lineThrough : null,
|
decoration: event.redacted ? TextDecoration.lineThrough : null,
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ReplyContent extends StatelessWidget {
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
replyEvent?.getLocalizedBody(context,
|
replyEvent?.getLocalizedBody(context,
|
||||||
withSenderNamePrefix: false, hideQuotes: true) ??
|
withSenderNamePrefix: false, hideReply: true) ??
|
||||||
"",
|
"",
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
|
|
|
@ -13,7 +13,7 @@ extension LocalizedBody on Event {
|
||||||
};
|
};
|
||||||
|
|
||||||
String getLocalizedBody(BuildContext context,
|
String getLocalizedBody(BuildContext context,
|
||||||
{bool withSenderNamePrefix = false, bool hideQuotes = false}) {
|
{bool withSenderNamePrefix = false, bool hideReply = false}) {
|
||||||
if (this.redacted) {
|
if (this.redacted) {
|
||||||
return I18n.of(context)
|
return I18n.of(context)
|
||||||
.removedBy(redactedBecause.sender.calcDisplayname());
|
.removedBy(redactedBecause.sender.calcDisplayname());
|
||||||
|
@ -209,11 +209,9 @@ extension LocalizedBody on Event {
|
||||||
localizedBody = I18n.of(context).unknownEvent(this.typeKey);
|
localizedBody = I18n.of(context).unknownEvent(this.typeKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide quotes
|
// Hide reply fallback
|
||||||
if (hideQuotes) {
|
if (hideReply) {
|
||||||
List<String> lines = localizedBody.split("\n");
|
localizedBody = localizedBody.replaceFirst(RegExp(r'^>( \*)? <@[a-zA-Z0-9-.=_\/]+:[^>]+>[^\n]+\r?\n(> [^\n]+\r?\n)*\r?\n'), "");
|
||||||
lines.removeWhere((s) => s.startsWith("> ") || s.isEmpty);
|
|
||||||
localizedBody = lines.join("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the sender name prefix
|
// Add the sender name prefix
|
||||||
|
|
Loading…
Reference in a new issue