Skip to content

Commit b998751

Browse files
committed
fix totalReactions
1 parent 5fb4e14 commit b998751

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/stream_feeds/lib/src/models/activity_data.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class ActivityData implements Identifiable {
5656
}
5757

5858
return copyWith(
59-
reactionCount: newLatestReactions.length,
59+
reactionCount: reactionGroups.totalCount,
6060
latestReactions: List.unmodifiable(newLatestReactions),
6161
ownReactions: List.unmodifiable(newOwnReactions),
6262
reactionGroups: Map.unmodifiable(newReactionGroups),
@@ -79,7 +79,7 @@ class ActivityData implements Identifiable {
7979
}
8080

8181
return copyWith(
82-
reactionCount: newLatestReactions.length,
82+
reactionCount: reactionGroups.totalCount,
8383
latestReactions: List.unmodifiable(newLatestReactions),
8484
ownReactions: List.unmodifiable(newOwnReactions),
8585
reactionGroups: Map.unmodifiable(newReactionGroups),
@@ -119,3 +119,8 @@ extension on FeedsReactionData {
119119
}
120120
}
121121
}
122+
123+
extension on Map<String, ReactionGroupData> {
124+
int get totalCount =>
125+
values.fold(0, (sum, reactionGroup) => sum + reactionGroup.count);
126+
}

0 commit comments

Comments
 (0)