diff --git a/README.md b/README.md index eccd411..dc153a1 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ A simple and user-friendly Matrix client made with Flutter and the Matrix Dart S - [x] Plain text - [x] HTML/Markdown - [x] Replies - - [ ] Choose ping on/off + - [x] Choose ping on/off - [ ] Attachments - [ ] Commands with [MSC4391](https://github.com/matrix-org/matrix-spec-proposals/pull/4391) - [x] Mentions diff --git a/lib/controllers/room_chat_controller.dart b/lib/controllers/room_chat_controller.dart index e7851f1..7ce7551 100644 --- a/lib/controllers/room_chat_controller.dart +++ b/lib/controllers/room_chat_controller.dart @@ -230,6 +230,7 @@ class RoomChatController extends AsyncNotifier { Future send( String message, { + bool shouldMention = true, required Iterable tags, required RelationType relationType, Message? relation, @@ -252,7 +253,9 @@ class RoomChatController extends AsyncNotifier { roomId: roomId, mentions: Mentions( userIds: [ - if (relation != null && relationType == RelationType.reply) + if (shouldMention == true && + relation != null && + relationType == RelationType.reply) relation.authorId, ].toIList(), room: taggedMessage.contains("@room"), diff --git a/lib/widgets/chat_page/chat_box.dart b/lib/widgets/chat_page/chat_box.dart index db51271..b9e7dbb 100644 --- a/lib/widgets/chat_page/chat_box.dart +++ b/lib/widgets/chat_page/chat_box.dart @@ -29,6 +29,7 @@ class ChatBox extends HookConsumerWidget { final theme = Theme.of(context); final controller = useRef(FlutterTaggerController()); final triggerCharacter = useState(""); + final shouldMention = useState(true); final query = useState(""); if (relationType == RelationType.edit && @@ -43,6 +44,7 @@ class ChatBox extends HookConsumerWidget { .watch(RoomChatController.provider(room.metadata!.id).notifier) .send( controller.value.formattedText, + shouldMention: shouldMention.value, relation: relatedMessage, relationType: relationType, tags: controller.value.tags, @@ -84,6 +86,9 @@ class ChatBox extends HookConsumerWidget { child: Column( children: [ RelationPreview( + shouldMention: shouldMention.value, + toggleShouldMention: () => + shouldMention.value = !shouldMention.value, relatedMessage: relatedMessage, relationType: relationType, onDismiss: onDismiss, diff --git a/lib/widgets/chat_page/relation_preview.dart b/lib/widgets/chat_page/relation_preview.dart index 7815096..b18b727 100644 --- a/lib/widgets/chat_page/relation_preview.dart +++ b/lib/widgets/chat_page/relation_preview.dart @@ -8,10 +8,14 @@ class RelationPreview extends ConsumerWidget { final Message? relatedMessage; final RelationType relationType; final VoidCallback onDismiss; + final bool shouldMention; + final VoidCallback toggleShouldMention; const RelationPreview({ required this.relatedMessage, required this.relationType, required this.onDismiss, + required this.shouldMention, + required this.toggleShouldMention, super.key, }); @@ -55,6 +59,18 @@ class RelationPreview extends ConsumerWidget { maxLines: 1, ), ), + + if (relationType == RelationType.reply) + TextButton( + onPressed: toggleShouldMention, + child: Text( + shouldMention ? "@On" : "@Off", + style: TextStyle( + fontWeight: FontWeight.w900, + color: shouldMention ? null : Theme.of(context).disabledColor, + ), + ), + ), IconButton( tooltip: "Cancel ${relationType == RelationType.edit ? "edit" : "reply"}",