diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index cd11340b..a2b07bf5 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -454,6 +454,13 @@ class MeshCoreConnector extends ChangeNotifier { ); } + Contact? getContactByPubKeyHex(String contactPubKeyHex) { + return _contacts.cast().firstWhere( + (c) => c?.publicKeyHex == contactPubKeyHex, + orElse: () => null, + ); + } + List get allContacts => List.unmodifiable([ ..._contacts, ..._discoveredContacts.where( @@ -3150,9 +3157,15 @@ class MeshCoreConnector extends ChangeNotifier { // Check if this is a reaction - apply locally with pending status and route through retry service final reactionInfo = ReactionHelper.parseReaction(text); if (reactionInfo != null) { + appLogger.info('Sending reaction: ${reactionInfo.identifier()}'); _conversations.putIfAbsent(contact.publicKeyHex, () => []); final messages = _conversations[contact.publicKeyHex]!; + // No check for duplicates. If you want to do it again to resend, you can. + final String reactionID = reactionInfo.identifier(); + _processedContactReactions.putIfAbsent(contact.publicKeyHex, () => {}); + _processedContactReactions[contact.publicKeyHex]!.add(reactionID); + // Apply reaction locally with pending status _processOutgoingContactReaction(messages, reactionInfo, contact); _setReactionStatus( @@ -3194,7 +3207,7 @@ class MeshCoreConnector extends ChangeNotifier { translatedLanguageCode: translatedLanguageCode, translationModelId: translationModelId, ); - _addMessage(contact.publicKeyHex, message); + _addMessage(contact.publicKeyHex, message); // recipient as "sender" notifyListeners(); final outboundText = prepareContactOutboundText(contact, text); await sendFrame(buildSendTextMsgFrame(contact.publicKey, outboundText)); @@ -3531,11 +3544,12 @@ class MeshCoreConnector extends ChangeNotifier { // Check if this is a reaction - if so, process it immediately instead of adding as a message final reactionInfo = ReactionHelper.parseReaction(text); if (reactionInfo != null) { + reactionInfo.senderName = selfName; // Check if we've already processed this reaction _processedChannelReactions.putIfAbsent(channel.index, () => {}); - final reactionIdentifier = - '${reactionInfo.targetHash}_${reactionInfo.emoji}'; + final reactionIdentifier = reactionInfo.identifier(); + // Maybe we should allow resending. Recipients can drop duplicates. if (_processedChannelReactions[channel.index]!.contains( reactionIdentifier, )) { @@ -3548,6 +3562,7 @@ class MeshCoreConnector extends ChangeNotifier { final messages = _channelMessages[channel.index]!; // Process reaction locally to update the UI immediately + appLogger.info('Adding sent channel reaction, id: $reactionIdentifier'); _processReaction(messages, reactionInfo); await _channelMessageStore.saveChannelMessages(channel.index, messages); @@ -6207,15 +6222,23 @@ class MeshCoreConnector extends ChangeNotifier { if (reactionInfo != null) { // Check if we've already processed this exact reaction _processedContactReactions.putIfAbsent(pubKeyHex, () => {}); - final reactionIdentifier = - '${reactionInfo.targetHash}_${reactionInfo.emoji}'; - + reactionInfo.senderName = _resolveContactSenderName(message, null, false); + final reactionIdentifier = reactionInfo.identifier(); final isDuplicate = _processedContactReactions[pubKeyHex]!.contains( reactionIdentifier, ); if (!isDuplicate) { // New reaction - process it + appLogger.info('Adding reaction, id: $reactionIdentifier'); + // For hashing and dup checking, we use null for sender names in + // normal 1:1 chats. This way if we and they have different ideas + // about what their name is, reactions still work. But for reaction + // reports, we want to know who sent what, rather than infer it later, + // so we'll add it to the reactionInfo before storing it. + reactionInfo.senderName ??= message.isOutgoing + ? selfName + : getContactByPubKeyHex(pubKeyHex)?.name ?? '???'; _processContactReaction(messages, reactionInfo, pubKeyHex); _messageStore.saveMessages(pubKeyHex, messages); @@ -6240,10 +6263,7 @@ class MeshCoreConnector extends ChangeNotifier { ReactionInfo reactionInfo, String contactPubKeyHex, ) { - final contact = _contacts.cast().firstWhere( - (c) => c?.publicKeyHex == contactPubKeyHex, - orElse: () => null, - ); + final contact = getContactByPubKeyHex(contactPubKeyHex); final isRoomServer = contact?.type == advTypeRoom; ReactionHelper.applyReaction( @@ -6292,10 +6312,7 @@ class MeshCoreConnector extends ChangeNotifier { ) { final messages = _conversations[pubKeyHex]; if (messages == null) return; - final contact = _contacts.cast().firstWhere( - (c) => c?.publicKeyHex == pubKeyHex, - orElse: () => null, - ); + final contact = getContactByPubKeyHex(pubKeyHex); final isRoomServer = contact?.type == advTypeRoom; for (int i = messages.length - 1; i >= 0; i--) { final msg = messages[i]; @@ -6454,12 +6471,11 @@ class MeshCoreConnector extends ChangeNotifier { final messages = _channelMessages[channelIndex]!; // Parse reaction info - final reactionInfo = ChannelMessage.parseReaction(message.text); + final reactionInfo = message.parseReaction(); if (reactionInfo != null) { // Check if we've already processed this exact reaction _processedChannelReactions.putIfAbsent(channelIndex, () => {}); - final reactionIdentifier = - '${reactionInfo.targetHash}_${reactionInfo.emoji}'; + final reactionIdentifier = reactionInfo.identifier(); final isDuplicate = _processedChannelReactions[channelIndex]!.contains( reactionIdentifier, @@ -6467,6 +6483,7 @@ class MeshCoreConnector extends ChangeNotifier { if (!isDuplicate) { // New reaction - process it + appLogger.info('Adding channel reaction, id: $reactionIdentifier'); _processReaction(messages, reactionInfo); // Save updated messages _channelMessageStore.saveChannelMessages(channelIndex, messages); diff --git a/lib/helpers/reaction_helper.dart b/lib/helpers/reaction_helper.dart index 36118ca3..18a72388 100644 --- a/lib/helpers/reaction_helper.dart +++ b/lib/helpers/reaction_helper.dart @@ -3,8 +3,17 @@ import '../widgets/emoji_picker.dart'; class ReactionInfo { final String targetHash; final String emoji; + String? senderName; - ReactionInfo({required this.targetHash, required this.emoji}); + ReactionInfo({ + required this.targetHash, + required this.emoji, + this.senderName, + }); + + String identifier() { + return '$targetHash:$emoji:${senderName ?? ""}'; + } } class ReactionHelper { @@ -26,9 +35,8 @@ class ReactionHelper { required int Function(T) getTimestampSecs, required String? Function(T) getSenderName, required String Function(T) getMessageText, - required Map Function(T) getReactions, + required Map> Function(T) getReactions, required bool Function(T) shouldSkip, - required void Function(int index, Map newReactions) updateMessage, }) { final targetHash = reactionInfo.targetHash; @@ -42,9 +50,12 @@ class ReactionHelper { getMessageText(msg), ); if (msgHash == targetHash) { - final currentReactions = Map.from(getReactions(msg)); - currentReactions[reactionInfo.emoji] = - (currentReactions[reactionInfo.emoji] ?? 0) + 1; + final currentReactions = Map>.from( + getReactions(msg), + ); + (currentReactions[reactionInfo.emoji] ??= []).add( + reactionInfo.senderName, + ); updateMessage(i, currentReactions); return true; } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index d1c79c6b..0eba0a3d 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -750,6 +750,7 @@ "chat_reply": "Reply", "chat_addReaction": "Add Reaction", "chat_me": "Me", + "reaction_report": "Emoji Reactions", "emojiCategorySmileys": "Smileys", "emojiCategoryGestures": "Gestures", "emojiCategoryHearts": "Hearts", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index c3fc41fc..d39927c1 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -2770,6 +2770,12 @@ abstract class AppLocalizations { /// **'Me'** String get chat_me; + /// No description provided for @reaction_report. + /// + /// In en, this message translates to: + /// **'Emoji Reactions'** + String get reaction_report; + /// No description provided for @emojiCategorySmileys. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index 55488ba0..fd203d9b 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -1510,6 +1510,9 @@ class AppLocalizationsBg extends AppLocalizations { @override String get chat_me => 'Аз'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Емотикони'; diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index 81e55c70..72616a7c 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -1509,6 +1509,9 @@ class AppLocalizationsDe extends AppLocalizations { @override String get chat_me => 'Ich'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emoticons'; diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 83337bd7..e5ef2128 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -1477,6 +1477,9 @@ class AppLocalizationsEn extends AppLocalizations { @override String get chat_me => 'Me'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Smileys'; diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index 9e0a2968..18699b3d 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -1505,6 +1505,9 @@ class AppLocalizationsEs extends AppLocalizations { @override String get chat_me => 'Yo'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emoticones'; diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index 91593114..93a4f411 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -1508,6 +1508,9 @@ class AppLocalizationsFr extends AppLocalizations { @override String get chat_me => 'Moi'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Émojis'; diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index 67f624a6..54593bf1 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -1500,6 +1500,9 @@ class AppLocalizationsHu extends AppLocalizations { @override String get chat_me => 'Nekem'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Hangulatjelek'; diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index adef0188..a4f3d621 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -1509,6 +1509,9 @@ class AppLocalizationsIt extends AppLocalizations { @override String get chat_me => 'Io'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emoji'; diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index 6ca5bbae..487a6b8d 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -1433,6 +1433,9 @@ class AppLocalizationsJa extends AppLocalizations { @override String get chat_me => '私'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => '顔文字'; diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index 8052f1d9..1e50a7da 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -1436,6 +1436,9 @@ class AppLocalizationsKo extends AppLocalizations { @override String get chat_me => '나'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => '이모티콘'; diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index dcaa1dde..f5803e83 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -1495,6 +1495,9 @@ class AppLocalizationsNl extends AppLocalizations { @override String get chat_me => 'Mijn'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emoji\'s'; diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index e632d0a8..3c9b0777 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -1518,6 +1518,9 @@ class AppLocalizationsPl extends AppLocalizations { @override String get chat_me => 'Ja'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emoji'; diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index 35ca7d70..3a98e222 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -1504,6 +1504,9 @@ class AppLocalizationsPt extends AppLocalizations { @override String get chat_me => 'Eu'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emojis'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index 5e72807f..090aa17b 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -1508,6 +1508,9 @@ class AppLocalizationsRu extends AppLocalizations { @override String get chat_me => 'Я'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Смайлы'; diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 55599371..a7dbedb3 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -1493,6 +1493,9 @@ class AppLocalizationsSk extends AppLocalizations { @override String get chat_me => 'Mne'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emoji'; diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index bc5fa9a5..92800763 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -1493,6 +1493,9 @@ class AppLocalizationsSl extends AppLocalizations { @override String get chat_me => 'jaz'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emoji'; diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index 809cb0f2..4d120227 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -1485,6 +1485,9 @@ class AppLocalizationsSv extends AppLocalizations { @override String get chat_me => 'Mig'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emojis'; diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index 14b92e8d..c82a7bfb 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -1499,6 +1499,9 @@ class AppLocalizationsUk extends AppLocalizations { @override String get chat_me => 'Я'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Емодзі'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index 24ace3a4..2a878584 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -1419,6 +1419,9 @@ class AppLocalizationsZh extends AppLocalizations { @override String get chat_me => '我'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => '表情'; diff --git a/lib/models/channel_message.dart b/lib/models/channel_message.dart index 0113c807..56bf4849 100644 --- a/lib/models/channel_message.dart +++ b/lib/models/channel_message.dart @@ -50,7 +50,7 @@ class ChannelMessage { final String? replyToMessageId; final String? replyToSenderName; final String? replyToText; - final Map reactions; + final Map> reactions; ChannelMessage({ this.senderKey, @@ -76,7 +76,7 @@ class ChannelMessage { this.replyToMessageId, this.replyToSenderName, this.replyToText, - Map? reactions, + Map>? reactions, }) : messageId = messageId ?? '${timestamp.millisecondsSinceEpoch}_${senderName.hashCode}_${text.hashCode}', @@ -107,7 +107,7 @@ class ChannelMessage { Object? translatedLanguageCode = _unset, MessageTranslationStatus? translationStatus, Object? translationModelId = _unset, - Map? reactions, + Map>? reactions, }) { return ChannelMessage( senderKey: senderKey, @@ -297,8 +297,32 @@ class ChannelMessage { ); } - static ReactionInfo? parseReaction(String text) { - return ReactionHelper.parseReaction(text); + ReactionInfo? parseReaction() { + final reactionInfo = ReactionHelper.parseReaction(text); + reactionInfo?.senderName = senderName; + return reactionInfo; + } + + String computeReactionHash() { + return ReactionHelper.computeReactionHash( + timestamp.millisecondsSinceEpoch ~/ 1000, + senderName, + text, + ); + } + + List reactionList() { + final String hash = computeReactionHash(); + List reactionList = []; + for (final entry in reactions.entries) { + final emoji = entry.key; + for (final senderName in entry.value) { + reactionList.add( + ReactionInfo(targetHash: hash, emoji: emoji, senderName: senderName), + ); + } + } + return reactionList; } } diff --git a/lib/models/message.dart b/lib/models/message.dart index e1395617..a9b7c0cd 100644 --- a/lib/models/message.dart +++ b/lib/models/message.dart @@ -8,7 +8,7 @@ enum MessageStatus { pending, sent, delivered, failed } class Message { static const Object _unset = Object(); - final Uint8List senderKey; + final Uint8List senderKey; // For outgoing msgs, gets used as recipientKey final String text; final DateTime timestamp; final bool isOutgoing; @@ -30,7 +30,7 @@ class Message { final int? tripTimeMs; final int? pathLength; final Uint8List pathBytes; - final Map reactions; + final Map> reactions; final Map reactionStatuses; final Uint8List fourByteRoomContactKey; @@ -56,7 +56,7 @@ class Message { this.pathLength, Uint8List? pathBytes, Uint8List? fourByteRoomContactKey, - Map? reactions, + Map>? reactions, Map? reactionStatuses, }) : messageId = messageId ?? @@ -84,7 +84,7 @@ class Message { Object? translatedLanguageCode = _unset, MessageTranslationStatus? translationStatus, Object? translationModelId = _unset, - Map? reactions, + Map>? reactions, Map? reactionStatuses, Uint8List? fourByteRoomContactKey, }) { diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index 29ea0beb..8926f78b 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -961,7 +961,7 @@ class _ChannelChatScreenState extends State { runSpacing: 6, children: message.reactions.entries.map((entry) { final emoji = entry.key; - final count = entry.value; + final int count = entry.value.length; return Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), @@ -970,35 +970,97 @@ class _ChannelChatScreenState extends State { borderRadius: BorderRadius.circular(MeshRadii.pill), border: Border.all(color: scheme.outlineVariant, width: 1), ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - emoji, - style: MeshTheme.emoji(fontSize: 16), - textHeightBehavior: const TextHeightBehavior( - applyHeightToFirstAscent: false, - applyHeightToLastDescent: false, - ), - ), - if (count > 1) ...[ - const SizedBox(width: 4), + child: InkWell( + onTap: () => _showReactionsReport(message), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ Text( - '$count', - style: MeshTheme.mono( - fontSize: 11, - fontWeight: FontWeight.w700, - color: scheme.onSurface, + emoji, + style: MeshTheme.emoji(fontSize: 16), + textHeightBehavior: const TextHeightBehavior( + applyHeightToFirstAscent: false, + applyHeightToLastDescent: false, ), ), + if (count > 1) ...[ + const SizedBox(width: 4), + Text( + '$count', + style: MeshTheme.mono( + fontSize: 11, + fontWeight: FontWeight.w700, + color: scheme.onSurface, + ), + ), + ], ], - ], + ), ), ); }).toList(), ); } + void _showReactionsReport(ChannelMessage message) { + final scheme = Theme.of(context).colorScheme; + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text(context.l10n.reaction_report), + content: SizedBox( + width: double.maxFinite, + child: Scrollbar( + child: ListView( + shrinkWrap: true, + padding: const EdgeInsets.symmetric(vertical: 4), + children: message.reactionList().map((reaction) { + return Container( + padding: const EdgeInsetsDirectional.symmetric(vertical: 4), + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + decoration: BoxDecoration( + color: scheme.surfaceContainerHigh, + borderRadius: BorderRadius.circular(MeshRadii.pill), + border: Border.all( + color: scheme.outlineVariant, + width: 1, + ), + ), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + reaction.emoji, + style: MeshTheme.emoji(fontSize: 16), + textHeightBehavior: const TextHeightBehavior( + applyHeightToFirstAscent: false, + applyHeightToLastDescent: false, + ), + ), + const SizedBox(width: 12), + Expanded(child: Text(reaction.senderName ?? '???')), + ], + ), + ), + ), + ); + }).toList(), + ), + ), + ), + ), + ); + } + Widget _buildPoiMessage( BuildContext context, MarkerPayload poi, @@ -2036,12 +2098,7 @@ class _ChannelChatScreenState extends State { final connector = context.read(); final emojiIndex = ReactionHelper.emojiToIndex(emoji); if (emojiIndex == null) return; // Unknown emoji, skip - final timestampSecs = message.timestamp.millisecondsSinceEpoch ~/ 1000; - final hash = ReactionHelper.computeReactionHash( - timestampSecs, - message.senderName, - message.text, - ); + final hash = message.computeReactionHash(); final reactionText = ReactionHelper.encodeReaction(hash, emojiIndex); connector.sendChannelMessage(widget.channel, reactionText); } diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart index bafa5f25..a15f4d85 100644 --- a/lib/screens/chat_screen.dart +++ b/lib/screens/chat_screen.dart @@ -7,6 +7,7 @@ import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; +import '../utils/app_logger.dart'; import '../utils/platform_info.dart'; import '../connector/meshcore_connector.dart'; @@ -1281,6 +1282,7 @@ class _ChatScreenState extends State { final senderName = liveContact.type == advTypeRoom ? senderContact.name : null; + appLogger.info('Sending reaction using senderName: $senderName'); final hash = ReactionHelper.computeReactionHash( timestampSecs, senderName, @@ -1654,7 +1656,7 @@ class _MessageBubble extends StatelessWidget { runSpacing: 6, children: message.reactions.entries.map((entry) { final emoji = entry.key; - final count = entry.value; + final count = entry.value.length; final status = message.reactionStatuses[emoji]; final isPending = status == MessageStatus.pending || status == MessageStatus.sent; diff --git a/lib/storage/channel_message_store.dart b/lib/storage/channel_message_store.dart index f16081a6..2d99f501 100644 --- a/lib/storage/channel_message_store.dart +++ b/lib/storage/channel_message_store.dart @@ -195,7 +195,12 @@ class ChannelMessageStore { replyToText: json['replyToText'] as String?, reactions: (json['reactions'] as Map?)?.map( - (key, value) => MapEntry(key, value as int), + (key, value) => MapEntry( + key, + (value is int) + ? List.filled(value, null) + : List.from(value), + ), ) ?? {}, ); diff --git a/lib/storage/message_store.dart b/lib/storage/message_store.dart index 96aaba9c..52f632b4 100644 --- a/lib/storage/message_store.dart +++ b/lib/storage/message_store.dart @@ -171,7 +171,12 @@ class MessageStore { pathBytes: decodedPathBytes, reactions: (json['reactions'] as Map?)?.map( - (key, value) => MapEntry(key, value as int), + (key, value) => MapEntry( + key, + (value is int) + ? List.filled(value, null) + : List.from(value), + ), ) ?? {}, reactionStatuses: diff --git a/untranslated.json b/untranslated.json index 9e26dfee..0967ef42 100644 --- a/untranslated.json +++ b/untranslated.json @@ -1 +1 @@ -{} \ No newline at end of file +{}