From 91e03f721239b9e502238b2afbeb4ea6cf3cb691 Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Tue, 24 Feb 2026 13:24:08 -0500 Subject: [PATCH] fix: save correct form for emoji uses, match example message tokens by lemma as fallback (#5787) --- .../analytics_details_popup/lemma_use_example_messages.dart | 5 +++-- lib/pangea/analytics_misc/lemma_emoji_setter_mixin.dart | 5 ++++- lib/pangea/toolbar/word_card/lemma_reaction_picker.dart | 3 +++ lib/pangea/toolbar/word_card/word_zoom_widget.dart | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/pangea/analytics_details_popup/lemma_use_example_messages.dart b/lib/pangea/analytics_details_popup/lemma_use_example_messages.dart index 761ffda8c..b3c38c890 100644 --- a/lib/pangea/analytics_details_popup/lemma_use_example_messages.dart +++ b/lib/pangea/analytics_details_popup/lemma_use_example_messages.dart @@ -22,7 +22,7 @@ class LemmaUseExampleMessages extends StatelessWidget { Future> _getExampleMessages() async { final List examples = []; for (final OneConstructUse use in construct.cappedUses) { - if (use.metadata.eventId == null || use.form == null || use.xp <= 0) { + if (use.metadata.eventId == null || use.form == null) { continue; } @@ -67,7 +67,8 @@ class LemmaUseExampleMessages extends StatelessWidget { final tokens = pangeaMessageEvent.messageDisplayRepresentation?.tokens; if (tokens == null || tokens.isEmpty) continue; final token = tokens.firstWhereOrNull( - (token) => token.text.content == use.form, + (token) => + token.text.content == use.form || token.lemma.text == use.lemma, ); if (token == null) continue; diff --git a/lib/pangea/analytics_misc/lemma_emoji_setter_mixin.dart b/lib/pangea/analytics_misc/lemma_emoji_setter_mixin.dart index b57cbcfbb..a1969b14f 100644 --- a/lib/pangea/analytics_misc/lemma_emoji_setter_mixin.dart +++ b/lib/pangea/analytics_misc/lemma_emoji_setter_mixin.dart @@ -17,6 +17,7 @@ mixin LemmaEmojiSetter { String? targetId, String? roomId, String? eventId, + String? form, ) async { final userL2 = MatrixState.pangeaController.userController.userL2?.langCodeShort; @@ -32,6 +33,7 @@ mixin LemmaEmojiSetter { targetId: targetId, roomId: roomId, eventId: eventId, + form: form, ); } @@ -99,6 +101,7 @@ mixin LemmaEmojiSetter { String? eventId, String? roomId, String? targetId, + String? form, }) { final constructs = [ OneConstructUse( @@ -111,7 +114,7 @@ mixin LemmaEmojiSetter { eventId: eventId, ), category: constructId.category, - form: constructId.lemma, + form: form ?? constructId.lemma, xp: ConstructUseTypeEnum.em.pointValue, ), ]; diff --git a/lib/pangea/toolbar/word_card/lemma_reaction_picker.dart b/lib/pangea/toolbar/word_card/lemma_reaction_picker.dart index d580b1d03..ca452a235 100644 --- a/lib/pangea/toolbar/word_card/lemma_reaction_picker.dart +++ b/lib/pangea/toolbar/word_card/lemma_reaction_picker.dart @@ -16,6 +16,7 @@ class LemmaReactionPicker extends StatefulWidget with LemmaEmojiSetter { final ConstructIdentifier constructId; final String langCode; final bool enabled; + final String? form; const LemmaReactionPicker({ super.key, @@ -23,6 +24,7 @@ class LemmaReactionPicker extends StatefulWidget with LemmaEmojiSetter { required this.langCode, this.event, this.enabled = true, + this.form, }); @override @@ -95,6 +97,7 @@ class LemmaReactionPickerState extends State { targetId, widget.event?.roomId, widget.event?.eventId, + widget.form, ); messenger = ScaffoldMessenger.of(context); widget.showLemmaEmojiSnackbar( diff --git a/lib/pangea/toolbar/word_card/word_zoom_widget.dart b/lib/pangea/toolbar/word_card/word_zoom_widget.dart index 0afd527f3..f3a9ebb4f 100644 --- a/lib/pangea/toolbar/word_card/word_zoom_widget.dart +++ b/lib/pangea/toolbar/word_card/word_zoom_widget.dart @@ -164,6 +164,7 @@ class WordZoomWidget extends StatelessWidget { langCode: langCode, event: event, enabled: enableEmojiSelection, + form: token.content, ), LemmaMeaningDisplay( langCode: langCode,