Merge pull request #3113 from pangeachat/3104-single-word-listen-practice-needs-fixing

chore: don't show match activities for single-word messages
pull/2245/head
ggurdin 5 months ago committed by GitHub
commit 8551b43f6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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;
}
}
}

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

Loading…
Cancel
Save