use latestReactions in reaction picker (like it's done in react sdk)

This commit is contained in:
Salvatore Giordano
2020-10-09 13:06:10 +02:00
parent 2f748b50c5
commit 62494e7a0a
+4 -3
View File
@@ -31,7 +31,7 @@ class ReactionPicker extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: reactionToEmoji.keys.map((reactionType) { children: reactionToEmoji.keys.map((reactionType) {
final ownReactionIndex = message.ownReactions final ownReactionIndex = message.latestReactions
?.indexWhere((reaction) => reaction.type == reactionType) ?? ?.indexWhere((reaction) => reaction.type == reactionType) ??
-1; -1;
return Column( return Column(
@@ -49,7 +49,7 @@ class ReactionPicker extends StatelessWidget {
onPressed: () { onPressed: () {
if (ownReactionIndex != -1) { if (ownReactionIndex != -1) {
removeReaction( removeReaction(
context, message.ownReactions[ownReactionIndex]); context, message.latestReactions[ownReactionIndex]);
} else { } else {
sendReaction(context, reactionType); sendReaction(context, reactionType);
} }
@@ -59,7 +59,8 @@ class ReactionPicker extends StatelessWidget {
? Padding( ? Padding(
padding: const EdgeInsets.only(bottom: 4.0), padding: const EdgeInsets.only(bottom: 4.0),
child: Text( child: Text(
message.ownReactions[ownReactionIndex].score.toString(), message.latestReactions[ownReactionIndex].score
.toString(),
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
), ),
) )