Merge pull request #175 from pangeachat/usability

If the user highlights a word and they’re not actively defining, then…
This commit is contained in:
ggurdin 2024-05-08 09:28:55 -04:00 committed by GitHub
commit c8fc3dbca8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -301,8 +301,13 @@ class MessageToolbarState extends State<MessageToolbar> {
widget.textSelection.selectionStream.stream.listen((value) {
timer?.cancel();
timer = Timer(const Duration(milliseconds: 500), () {
if (currentMode != null || value != null && value.isNotEmpty) {
updateMode(currentMode ?? MessageMode.translation);
if (value != null && value.isNotEmpty) {
final MessageMode newMode = currentMode == MessageMode.definition
? MessageMode.definition
: MessageMode.translation;
updateMode(newMode);
} else if (currentMode != null) {
updateMode(currentMode!);
}
});
});