tweaking criteria for determining existing activity

pull/1490/head
William Jordan-Cooley 1 year ago
parent 653ee5f75f
commit 51bff65a8b

@ -27,19 +27,17 @@ class TargetTokensAndActivityType {
return false; return false;
} }
// check that the activity matches at least one construct in the target tokens // This is kind of complicated
// TODO - this is complicated so we need to verify it works // if it's causing problems,
// maybe we just verify that the target span of the activity is the same as the target span of the target // maybe we just verify that the target span of the activity is the same as the target span of the target?
final allTokenConstructs = final List<ConstructIdentifier> allTokenConstructs = tokens
tokens.map((t) => t.constructs).expand((e) => e).toList(); .map((t) => t.constructs)
for (final c in allTokenConstructs) { .expand((e) => e)
if (activity.tgtConstructs.any((tc) => tc == c.id)) { .map((c) => c.id)
debugPrint('found existing activity'); .where(activityType.constructFilter)
return true; .toList();
}
} return listEquals(activity.tgtConstructs, allTokenConstructs);
return false;
} }
@override @override

@ -1,4 +1,6 @@
import 'package:fluffychat/pangea/enum/construct_type_enum.dart';
import 'package:fluffychat/pangea/enum/construct_use_type_enum.dart'; import 'package:fluffychat/pangea/enum/construct_use_type_enum.dart';
import 'package:fluffychat/pangea/models/practice_activities.dart/practice_activity_model.dart';
enum ActivityTypeEnum { wordMeaning, wordFocusListening, hiddenWordListening } enum ActivityTypeEnum { wordMeaning, wordFocusListening, hiddenWordListening }
@ -68,4 +70,14 @@ extension ActivityTypeExtension on ActivityTypeEnum {
]; ];
} }
} }
/// Filters out constructs that are not relevant to the activity type
bool Function(ConstructIdentifier) get constructFilter {
switch (this) {
case ActivityTypeEnum.wordMeaning:
case ActivityTypeEnum.wordFocusListening:
case ActivityTypeEnum.hiddenWordListening:
return (id) => id.type == ConstructTypeEnum.vocab;
}
}
} }

@ -23,7 +23,6 @@ class WordAudioButtonState extends State<WordAudioButton> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
debugPrint('build WordAudioButton');
return IconButton( return IconButton(
icon: const Icon(Icons.play_arrow_outlined), icon: const Icon(Icons.play_arrow_outlined),
isSelected: _isPlaying, isSelected: _isPlaying,

Loading…
Cancel
Save