Add emoji reaction report for channel chat, fix reaction deduping bug
In channel chat screen, clicking a reaction emoji brings up a popup listing the received emoji reactions and their senders. Also fixes a bug that prevented displaying the count numbers on reactions. Code existed to display counts for multiples, but the deduplication failed to differentiate between senders and was tossing them out. There is still another preexisting bug, not fixed by this commit, that over-counts sent reactions in rooms.
This commit is contained in:
1 parent
98f6cf3745
commit
76b34779cf
29 files changed
+265
-73
No files matched your search
@@ -50,7 +50,7 @@ class ChannelMessage {
|
||||
final String? replyToMessageId;
|
||||
final String? replyToSenderName;
|
||||
final String? replyToText;
|
||||
final Map<String, int> reactions;
|
||||
final Map<String, List<String?>> reactions;
|
||||
|
||||
ChannelMessage({
|
||||
this.senderKey,
|
||||
@@ -76,7 +76,7 @@ class ChannelMessage {
|
||||
this.replyToMessageId,
|
||||
this.replyToSenderName,
|
||||
this.replyToText,
|
||||
Map<String, int>? reactions,
|
||||
Map<String, List<String?>>? reactions,
|
||||
}) : messageId =
|
||||
messageId ??
|
||||
'${timestamp.millisecondsSinceEpoch}_${senderName.hashCode}_${text.hashCode}',
|
||||
@@ -107,7 +107,7 @@ class ChannelMessage {
|
||||
Object? translatedLanguageCode = _unset,
|
||||
MessageTranslationStatus? translationStatus,
|
||||
Object? translationModelId = _unset,
|
||||
Map<String, int>? reactions,
|
||||
Map<String, List<String?>>? 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<ReactionInfo> reactionList() {
|
||||
final String hash = computeReactionHash();
|
||||
List<ReactionInfo> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<String, int> reactions;
|
||||
final Map<String, List<String?>> reactions;
|
||||
final Map<String, MessageStatus> reactionStatuses;
|
||||
final Uint8List fourByteRoomContactKey;
|
||||
|
||||
@@ -56,7 +56,7 @@ class Message {
|
||||
this.pathLength,
|
||||
Uint8List? pathBytes,
|
||||
Uint8List? fourByteRoomContactKey,
|
||||
Map<String, int>? reactions,
|
||||
Map<String, List<String?>>? reactions,
|
||||
Map<String, MessageStatus>? reactionStatuses,
|
||||
}) : messageId =
|
||||
messageId ??
|
||||
@@ -84,7 +84,7 @@ class Message {
|
||||
Object? translatedLanguageCode = _unset,
|
||||
MessageTranslationStatus? translationStatus,
|
||||
Object? translationModelId = _unset,
|
||||
Map<String, int>? reactions,
|
||||
Map<String, List<String?>>? reactions,
|
||||
Map<String, MessageStatus>? reactionStatuses,
|
||||
Uint8List? fourByteRoomContactKey,
|
||||
}) {
|
||||
|
||||
Reference in new issue
Block a user