forked from Henry-Hiles/nexus
make mention optional for replies
This commit is contained in:
parent
263ad5ab4a
commit
eaebea4d44
4 changed files with 26 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -230,6 +230,7 @@ class RoomChatController extends AsyncNotifier<ChatController> {
|
|||
|
||||
Future<void> send(
|
||||
String message, {
|
||||
bool shouldMention = true,
|
||||
required Iterable<Tag> tags,
|
||||
required RelationType relationType,
|
||||
Message? relation,
|
||||
|
|
@ -252,7 +253,9 @@ class RoomChatController extends AsyncNotifier<ChatController> {
|
|||
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"),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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"}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue