diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index 10395de9ed..8b8969181a 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -678,15 +678,15 @@ class ChatController extends State eventId: msgEventId, ); - if (msgEventId != null) { + if (msgEventId != null && originalSent != null && tokensSent != null) { pangeaController.putAnalytics.setState( AnalyticsStream( eventId: msgEventId, roomId: room.id, constructs: [ - ...originalSent!.vocabAndMorphUses( + ...originalSent.vocabAndMorphUses( choreo: choreo, - tokens: tokensSent!.tokens, + tokens: tokensSent.tokens, metadata: metadata, ), ], diff --git a/lib/pangea/choreographer/controllers/choreographer.dart b/lib/pangea/choreographer/controllers/choreographer.dart index 3e13549f6c..151c0eb82b 100644 --- a/lib/pangea/choreographer/controllers/choreographer.dart +++ b/lib/pangea/choreographer/controllers/choreographer.dart @@ -68,6 +68,7 @@ class Choreographer { } void send(BuildContext context) { + debugPrint("can send message: $canSendMessage"); if (!canSendMessage) { if (igc.igcTextData != null) { igc.showFirstMatch(context); @@ -145,8 +146,9 @@ class Choreographer { // 2) that this call is being made after we've determined if we have an applicable choreo in order to // say whether correction was run on the message. we may eventually want // to edit the useType after - if (igc.igcTextData?.tokens == null || - igc.igcTextData?.detectedLanguage == null) { + if ((l2Lang != null && l1Lang != null) && + (igc.igcTextData?.tokens == null || + igc.igcTextData?.detectedLanguage == null)) { await igc.getIGCTextData(onlyTokensAndLanguageDetection: true); } @@ -255,6 +257,8 @@ class Choreographer { pangeaController.subscriptionController.subscriptionStatus; if (canSendStatus != SubscriptionStatus.subscribed || + l2Lang == null || + l1Lang == null || (!igcEnabled && !itEnabled) || (!isAutoIGCEnabled && !manual && choreoMode != ChoreoMode.it)) { return; @@ -597,7 +601,7 @@ class Choreographer { bool get canSendMessage { // if there's an error, let them send. we don't want to block them from sending in this case - if (errorService.isError) return true; + if (errorService.isError || l2Lang == null || l1Lang == null) return true; // if they're in IT mode, don't let them send if (itEnabled && isRunningIT) return false; diff --git a/lib/pangea/controllers/language_controller.dart b/lib/pangea/controllers/language_controller.dart index ccd33761fa..2a34b1fb4b 100644 --- a/lib/pangea/controllers/language_controller.dart +++ b/lib/pangea/controllers/language_controller.dart @@ -40,11 +40,19 @@ class LanguageController { } LanguageModel? get userL1 { - return _userL1Code != null ? PangeaLanguage.byLangCode(_userL1Code!) : null; + if (_userL1Code == null) return null; + final langModel = PangeaLanguage.byLangCode(_userL1Code!); + return langModel.langCode == LanguageKeys.unknownLanguage + ? null + : langModel; } LanguageModel? get userL2 { - return _userL2Code != null ? PangeaLanguage.byLangCode(_userL2Code!) : null; + if (_userL2Code == null) return null; + final langModel = PangeaLanguage.byLangCode(_userL2Code!); + return langModel.langCode == LanguageKeys.unknownLanguage + ? null + : langModel; } String? activeL1Code() {