diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ca3aa04..af482426 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.20+3 + +- Fix reaction picker score indicator + ## 0.2.20+2 - Added `shouldAddChannel` to ChannelsBloc in order to check if a channel has to be added to the list when a new message arrives diff --git a/lib/src/reaction_picker.dart b/lib/src/reaction_picker.dart index bdbcc669..8e2d8b10 100644 --- a/lib/src/reaction_picker.dart +++ b/lib/src/reaction_picker.dart @@ -31,9 +31,17 @@ class ReactionPicker extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: reactionToEmoji.keys.map((reactionType) { - final ownReactionIndex = message.latestReactions - ?.indexWhere((reaction) => reaction.type == reactionType) ?? + var user = StreamChat.of(context).user; + final ownReactionIndex = message.latestReactions?.indexWhere( + (reaction) => + reaction.type == reactionType && + reaction.userId == user.id) ?? -1; + final totalScore = message.latestReactions + .where((r) => r.type == reactionType) + .map((r) => r.score) + .fold(0, (tot, s) => tot + s); + return Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, @@ -55,12 +63,11 @@ class ReactionPicker extends StatelessWidget { } }, ), - ownReactionIndex != -1 + totalScore > 0 ? Padding( padding: const EdgeInsets.only(bottom: 4.0), child: Text( - message.latestReactions[ownReactionIndex].score - .toString(), + totalScore.toString(), style: TextStyle(color: Colors.white), ), ) diff --git a/pubspec.yaml b/pubspec.yaml index 7aac0211..1b14a71c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.20+2 +version: 0.2.20+3 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues