diff --git a/lib/pangea/widgets/chat/message_toolbar.dart b/lib/pangea/widgets/chat/message_toolbar.dart index 5b91181c1..aa8a1de7b 100644 --- a/lib/pangea/widgets/chat/message_toolbar.dart +++ b/lib/pangea/widgets/chat/message_toolbar.dart @@ -247,14 +247,16 @@ class MessageToolbarState extends State { updateMode(mode); }); + Timer? timer; + selectionStream = widget.textSelection.selectionStream.stream.listen((value) { - final bool shouldSetState = - value != null && !hasSelectedText || value == null && hasSelectedText; - hasSelectedText = value != null; - if (shouldSetState) { - setState(() {}); - } + timer?.cancel(); + timer = Timer(const Duration(milliseconds: 750), () { + if (currentMode != null || value != null && value.isNotEmpty) { + updateMode(currentMode ?? MessageMode.translation); + } + }); }); }