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
@@ -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<String, int> Function(T) getReactions,
|
||||
required Map<String, List<String?>> Function(T) getReactions,
|
||||
required bool Function(T) shouldSkip,
|
||||
required void Function(int index, Map<String, int> newReactions)
|
||||
updateMessage,
|
||||
}) {
|
||||
final targetHash = reactionInfo.targetHash;
|
||||
@@ -42,9 +50,12 @@ class ReactionHelper {
|
||||
getMessageText(msg),
|
||||
);
|
||||
if (msgHash == targetHash) {
|
||||
final currentReactions = Map<String, int>.from(getReactions(msg));
|
||||
currentReactions[reactionInfo.emoji] =
|
||||
(currentReactions[reactionInfo.emoji] ?? 0) + 1;
|
||||
final currentReactions = Map<String, List<String?>>.from(
|
||||
getReactions(msg),
|
||||
);
|
||||
(currentReactions[reactionInfo.emoji] ??= []).add(
|
||||
reactionInfo.senderName,
|
||||
);
|
||||
updateMessage(i, currentReactions);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user