go straight to translation if message not in target language (#1176)

pull/1544/head
ggurdin 11 months ago committed by GitHub
parent 2840a7dcfd
commit 191607abcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -170,6 +170,10 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
}
}
bool get messageInUserL2 =>
pangeaMessageEvent?.messageDisplayLangCode ==
MatrixState.pangeaController.languageController.userL2?.langCode;
Future<void> _setInitialToolbarMode() async {
if (widget._pangeaMessageEvent?.isAudioMessage ?? false) {
toolbarMode = MessageMode.speechToText;
@ -180,7 +184,7 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
// 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);
}

@ -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,

Loading…
Cancel
Save