From 85a103c5fc8785698a56e6a9b83e5fc4447cea87 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 18 Jan 2021 15:06:43 +0530 Subject: [PATCH 1/4] fix: get reaction by user and reaction type --- lib/src/reaction_picker.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/src/reaction_picker.dart b/lib/src/reaction_picker.dart index bdbcc669..8d1c6d7b 100644 --- a/lib/src/reaction_picker.dart +++ b/lib/src/reaction_picker.dart @@ -31,8 +31,11 @@ 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; return Column( mainAxisSize: MainAxisSize.min, From 835c73204a3c7324dc4082ea8314808fd44b8e67 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 18 Jan 2021 11:10:40 +0100 Subject: [PATCH 2/4] fix reaction picker score indicator --- lib/src/reaction_picker.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/src/reaction_picker.dart b/lib/src/reaction_picker.dart index 8d1c6d7b..94bd9162 100644 --- a/lib/src/reaction_picker.dart +++ b/lib/src/reaction_picker.dart @@ -37,6 +37,10 @@ class ReactionPicker extends StatelessWidget { reaction.type == reactionType && reaction.userId == user.id) ?? -1; + final totalScore = message.latestReactions + .where((r) => r.type == reactionType) + .map((r) => r.score) + .reduce((tot, s) => tot + s); return Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, @@ -58,12 +62,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), ), ) From 8ddd75707fb8deb4589d604cd9dc4e4ad4c754f5 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 18 Jan 2021 16:12:20 +0530 Subject: [PATCH 3/4] fix: removed bad state --- lib/src/reaction_picker.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/reaction_picker.dart b/lib/src/reaction_picker.dart index 94bd9162..8e2d8b10 100644 --- a/lib/src/reaction_picker.dart +++ b/lib/src/reaction_picker.dart @@ -40,7 +40,8 @@ class ReactionPicker extends StatelessWidget { final totalScore = message.latestReactions .where((r) => r.type == reactionType) .map((r) => r.score) - .reduce((tot, s) => tot + s); + .fold(0, (tot, s) => tot + s); + return Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, From b5fd401df6ddccad61a4e76c82bd57341dfcd4d9 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 18 Jan 2021 11:58:36 +0100 Subject: [PATCH 4/4] version bp --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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/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