chore: don't show match activities for single-word messages

This commit is contained in:
ggurdin 2025-06-17 13:39:46 -04:00
parent 31f1632b91
commit 233e5162d1
No known key found for this signature in database
GPG key ID: A01CB41737CBB478
2 changed files with 21 additions and 0 deletions

View file

@ -190,4 +190,20 @@ extension ActivityTypeExtension on ActivityTypeEnum {
return null; // TODO: Add to L10n
}
}
/// The minimum number of tokens in a message for this activity type to be available.
/// Matching activities don't make sense for a single-word message.
int get minTokensForMatchActivity {
switch (this) {
case ActivityTypeEnum.wordMeaning:
case ActivityTypeEnum.lemmaId:
case ActivityTypeEnum.wordFocusListening:
return 2;
case ActivityTypeEnum.hiddenWordListening:
case ActivityTypeEnum.emoji:
case ActivityTypeEnum.morphId:
case ActivityTypeEnum.messageMeaning:
return 1;
}
}
}

View file

@ -155,6 +155,11 @@ class PracticeSelection {
return [];
}
if (tokens.length < activityType.minTokensForMatchActivity) {
// if we only have one token, we don't need to do an emoji activity
return [];
}
return [
PracticeTarget(
activityType: activityType,