From 99bc8198e968d47ca97fb97ad0d91c7cc7a1af17 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Tue, 20 Jul 2021 17:54:48 +0200 Subject: [PATCH] feat: Nicer mentions --- lib/pages/views/chat_view.dart | 4 ++-- lib/widgets/input_bar.dart | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pages/views/chat_view.dart b/lib/pages/views/chat_view.dart index 412a157f..eb6c3cfe 100644 --- a/lib/pages/views/chat_view.dart +++ b/lib/pages/views/chat_view.dart @@ -86,7 +86,7 @@ class ChatView extends StatelessWidget { outerContext: context, onMention: () => controller .sendController.text += - '${controller.room.directChatMatrixID} ', + '${controller.room.getUserByMXIDSync(controller.room.directChatMatrixID).mention} ', ), ) : () => VRouter.of(context) @@ -376,7 +376,7 @@ class ChatView extends StatelessWidget { onMention: () => controller .sendController .text += - '${event.senderId} ', + '${event.sender.mention} ', ), ), unfold: controller.unfold, diff --git a/lib/widgets/input_bar.dart b/lib/widgets/input_bar.dart index 1c9650fd..1bb1648c 100644 --- a/lib/widgets/input_bar.dart +++ b/lib/widgets/input_bar.dart @@ -115,6 +115,7 @@ class InputBar extends StatelessWidget { ret.add({ 'type': 'user', 'mxid': user.id, + 'mention': user.mention, 'displayname': user.displayName, 'avatar_url': user.avatarUrl?.toString(), }); @@ -324,7 +325,7 @@ class InputBar extends StatelessWidget { ); } if (suggestion['type'] == 'user') { - insertText = suggestion['mxid'] + ' '; + insertText = suggestion['mention'] + ' '; startText = replaceText.replaceAllMapped( RegExp(r'(\s|^)(@[-\w]+)$'), (Match m) => '${m[1]}$insertText',