From 191607abcf1228717772e48f016b26c3cfa2f12f Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Fri, 6 Dec 2024 14:54:21 -0500 Subject: [PATCH] go straight to translation if message not in target language (#1176) --- lib/pangea/widgets/chat/message_selection_overlay.dart | 6 +++++- lib/pangea/widgets/chat/message_toolbar.dart | 6 +----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pangea/widgets/chat/message_selection_overlay.dart b/lib/pangea/widgets/chat/message_selection_overlay.dart index ecdaa21bf..d939d31da 100644 --- a/lib/pangea/widgets/chat/message_selection_overlay.dart +++ b/lib/pangea/widgets/chat/message_selection_overlay.dart @@ -170,6 +170,10 @@ class MessageOverlayController extends State } } + bool get messageInUserL2 => + pangeaMessageEvent?.messageDisplayLangCode == + MatrixState.pangeaController.languageController.userL2?.langCode; + Future _setInitialToolbarMode() async { if (widget._pangeaMessageEvent?.isAudioMessage ?? false) { toolbarMode = MessageMode.speechToText; @@ -180,7 +184,7 @@ class MessageOverlayController extends State // 2) if the user selects a span on initialization, then we want to give // them a practice activity on that word // 3) if the user has activities left to complete, then we want to give them - if (tokens != null && activitiesLeftToComplete > 0) { + if (tokens != null && activitiesLeftToComplete > 0 && messageInUserL2) { return setState(() => toolbarMode = MessageMode.practiceActivity); } diff --git a/lib/pangea/widgets/chat/message_toolbar.dart b/lib/pangea/widgets/chat/message_toolbar.dart index 849fc18a0..7e98d3981 100644 --- a/lib/pangea/widgets/chat/message_toolbar.dart +++ b/lib/pangea/widgets/chat/message_toolbar.dart @@ -51,10 +51,6 @@ class MessageToolbar extends StatelessWidget { return const ToolbarContentLoadingIndicator(); } - // Check if the message is in the user's second language - final bool messageInUserL2 = pangeaMessageEvent.messageDisplayLangCode == - MatrixState.pangeaController.languageController.userL2?.langCode; - switch (overLayController.toolbarMode) { case MessageMode.translation: return MessageTranslationCard( @@ -127,7 +123,7 @@ class MessageToolbar extends StatelessWidget { } case MessageMode.practiceActivity: // If not in the target language show specific messsage - if (!messageInUserL2) { + if (!overLayController.messageInUserL2) { return MessageDisplayCard( displayText: L10n.of(context)! .messageNotInTargetLang, // Pass the display text,