don't call grammar_lite if l1 or l2 are unknown

pull/1490/head
ggurdin 1 year ago
parent 59963e283a
commit 3b3c8729f5
No known key found for this signature in database
GPG Key ID: A01CB41737CBB478

@ -678,15 +678,15 @@ class ChatController extends State<ChatPageWithRoom>
eventId: msgEventId, eventId: msgEventId,
); );
if (msgEventId != null) { if (msgEventId != null && originalSent != null && tokensSent != null) {
pangeaController.putAnalytics.setState( pangeaController.putAnalytics.setState(
AnalyticsStream( AnalyticsStream(
eventId: msgEventId, eventId: msgEventId,
roomId: room.id, roomId: room.id,
constructs: [ constructs: [
...originalSent!.vocabAndMorphUses( ...originalSent.vocabAndMorphUses(
choreo: choreo, choreo: choreo,
tokens: tokensSent!.tokens, tokens: tokensSent.tokens,
metadata: metadata, metadata: metadata,
), ),
], ],

@ -68,6 +68,7 @@ class Choreographer {
} }
void send(BuildContext context) { void send(BuildContext context) {
debugPrint("can send message: $canSendMessage");
if (!canSendMessage) { if (!canSendMessage) {
if (igc.igcTextData != null) { if (igc.igcTextData != null) {
igc.showFirstMatch(context); 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 // 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 // say whether correction was run on the message. we may eventually want
// to edit the useType after // to edit the useType after
if (igc.igcTextData?.tokens == null || if ((l2Lang != null && l1Lang != null) &&
igc.igcTextData?.detectedLanguage == null) { (igc.igcTextData?.tokens == null ||
igc.igcTextData?.detectedLanguage == null)) {
await igc.getIGCTextData(onlyTokensAndLanguageDetection: true); await igc.getIGCTextData(onlyTokensAndLanguageDetection: true);
} }
@ -255,6 +257,8 @@ class Choreographer {
pangeaController.subscriptionController.subscriptionStatus; pangeaController.subscriptionController.subscriptionStatus;
if (canSendStatus != SubscriptionStatus.subscribed || if (canSendStatus != SubscriptionStatus.subscribed ||
l2Lang == null ||
l1Lang == null ||
(!igcEnabled && !itEnabled) || (!igcEnabled && !itEnabled) ||
(!isAutoIGCEnabled && !manual && choreoMode != ChoreoMode.it)) { (!isAutoIGCEnabled && !manual && choreoMode != ChoreoMode.it)) {
return; return;
@ -597,7 +601,7 @@ class Choreographer {
bool get canSendMessage { bool get canSendMessage {
// if there's an error, let them send. we don't want to block them from sending in this case // 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 they're in IT mode, don't let them send
if (itEnabled && isRunningIT) return false; if (itEnabled && isRunningIT) return false;

@ -40,11 +40,19 @@ class LanguageController {
} }
LanguageModel? get userL1 { 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 { 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() { String? activeL1Code() {

Loading…
Cancel
Save