From cb3f4d191c77f2cf60de185d44b018ae6c05aec8 Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Tue, 2 Sep 2025 14:06:57 -0400 Subject: [PATCH] fix: only pass one emoji match option per token in emoji match activity (#3844) --- .../message_token_text/message_token_button.dart | 9 ++++++++- .../emoji_activity_generator.dart | 14 ++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/pangea/message_token_text/message_token_button.dart b/lib/pangea/message_token_text/message_token_button.dart index ec1293b95..e5aeccaf1 100644 --- a/lib/pangea/message_token_text/message_token_button.dart +++ b/lib/pangea/message_token_text/message_token_button.dart @@ -312,7 +312,14 @@ class MessageTokenButtonContent extends StatelessWidget { return SizedBox( height: height, child: Text( - token.vocabConstructID.userSetEmoji.firstOrNull ?? '', + activity?.record.responses + .firstWhereOrNull( + (res) => + res.cId == token.vocabConstructID && res.isCorrect, + ) + ?.text ?? + token.vocabConstructID.userSetEmoji.firstOrNull ?? + '', style: _emojiStyle, ), ); diff --git a/lib/pangea/practice_activities/emoji_activity_generator.dart b/lib/pangea/practice_activities/emoji_activity_generator.dart index 3058d4805..03322a5cf 100644 --- a/lib/pangea/practice_activities/emoji_activity_generator.dart +++ b/lib/pangea/practice_activities/emoji_activity_generator.dart @@ -1,4 +1,5 @@ import 'package:fluffychat/pangea/constructs/construct_form.dart'; +import 'package:fluffychat/pangea/events/models/pangea_token_model.dart'; import 'package:fluffychat/pangea/lemmas/lemma_info_response.dart'; import 'package:fluffychat/pangea/practice_activities/activity_type_enum.dart'; import 'package:fluffychat/pangea/practice_activities/message_activity_request.dart'; @@ -20,16 +21,17 @@ class EmojiActivityGenerator { MessageActivityRequest req, ) async { final Map> matchInfo = {}; + final List missingEmojis = []; for (final token in req.targetTokens) { final List userSavedEmojis = token.vocabConstructID.userSetEmoji; if (userSavedEmojis.isNotEmpty) { - matchInfo[token.vocabForm] = userSavedEmojis; + matchInfo[token.vocabForm] = [userSavedEmojis.first]; } else { - matchInfo[token.vocabForm] = []; + missingEmojis.add(token); } } - final List> lemmaInfoFutures = req.targetTokens + final List> lemmaInfoFutures = missingEmojis .map((token) => token.vocabConstructID.getLemmaInfo()) .toList(); @@ -38,8 +40,12 @@ class EmojiActivityGenerator { for (int i = 0; i < req.targetTokens.length; i++) { final formKey = req.targetTokens[i].vocabForm; + if (matchInfo[formKey] != null && matchInfo[formKey]!.isNotEmpty) { + continue; // Skip if user has already set emojis + } + matchInfo[formKey] ??= []; - matchInfo[formKey]!.addAll(lemmaInfos[i].emoji); + matchInfo[formKey]!.add(lemmaInfos[i].emoji.first); } return MessageActivityResponse(