Skip to content

Commit

Permalink
don't call grammar_lite if l1 or l2 are unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
ggurdin committed Nov 11, 2024
1 parent 59963e2 commit 3b3c872
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/pages/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -678,15 +678,15 @@ class ChatController extends State<ChatPageWithRoom>
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,
),
],
Expand Down
10 changes: 7 additions & 3 deletions lib/pangea/choreographer/controllers/choreographer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Choreographer {
}

void send(BuildContext context) {
debugPrint("can send message: $canSendMessage");
if (!canSendMessage) {
if (igc.igcTextData != null) {
igc.showFirstMatch(context);
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 10 additions & 2 deletions lib/pangea/controllers/language_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 3b3c872

Please sign in to comment.