chore: redact already-sent emoji reactions on select identical reaction in word zoom widget (#3447)
This commit is contained in:
parent
657b652bc2
commit
32355ddffd
2 changed files with 31 additions and 5 deletions
|
|
@ -1,20 +1,25 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/pages/chat/chat.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/constructs/construct_identifier.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/reading_assistance_input_row/lemma_emoji_choice_item.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
|
||||
class LemmaReactionPicker extends StatefulWidget {
|
||||
final ConstructIdentifier cId;
|
||||
final String eventId;
|
||||
final Event event;
|
||||
final ChatController controller;
|
||||
final double? iconSize;
|
||||
|
||||
const LemmaReactionPicker({
|
||||
super.key,
|
||||
required this.cId,
|
||||
required this.eventId,
|
||||
required this.event,
|
||||
required this.controller,
|
||||
this.iconSize,
|
||||
});
|
||||
|
|
@ -41,10 +46,31 @@ class LemmaReactionPickerState extends State<LemmaReactionPicker> {
|
|||
}
|
||||
}
|
||||
|
||||
void setEmoji(String emoji) => widget.controller.room.sendReaction(
|
||||
widget.eventId,
|
||||
void setEmoji(String emoji) {
|
||||
final allReactionEvents = widget.event.aggregatedEvents(
|
||||
widget.controller.timeline!,
|
||||
RelationshipTypes.reaction,
|
||||
);
|
||||
|
||||
final client = Matrix.of(context).client;
|
||||
final reactionEvent = allReactionEvents.firstWhereOrNull(
|
||||
(e) =>
|
||||
e.senderId == client.userID &&
|
||||
e.content.tryGetMap('m.relates_to')?['key'] == emoji,
|
||||
);
|
||||
|
||||
if (reactionEvent != null) {
|
||||
showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => reactionEvent.redactEvent(),
|
||||
);
|
||||
} else {
|
||||
widget.controller.room.sendReaction(
|
||||
widget.event.eventId,
|
||||
emoji,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _refresh() async {
|
||||
setState(() {
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ class WordZoomWidget extends StatelessWidget {
|
|||
),
|
||||
LemmaReactionPicker(
|
||||
cId: _selectedToken.vocabConstructID,
|
||||
eventId: messageEvent.eventId,
|
||||
event: messageEvent.event,
|
||||
controller: overlayController.widget.chatController,
|
||||
),
|
||||
if (controller.error != null)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue