fix: save correct form for emoji uses, match example message tokens by lemma as fallback (#5787)

This commit is contained in:
ggurdin 2026-02-24 13:24:08 -05:00 committed by GitHub
parent 22c69df097
commit 91e03f7212
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 3 deletions

View file

@ -22,7 +22,7 @@ class LemmaUseExampleMessages extends StatelessWidget {
Future<List<ExampleMessage>> _getExampleMessages() async {
final List<ExampleMessage> 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;

View file

@ -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,
),
];

View file

@ -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<LemmaReactionPicker> {
targetId,
widget.event?.roomId,
widget.event?.eventId,
widget.form,
);
messenger = ScaffoldMessenger.of(context);
widget.showLemmaEmojiSnackbar(

View file

@ -164,6 +164,7 @@ class WordZoomWidget extends StatelessWidget {
langCode: langCode,
event: event,
enabled: enableEmojiSelection,
form: token.content,
),
LemmaMeaningDisplay(
langCode: langCode,