From 5ace429216a508e122466101271a247a5f4e63d2 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Mon, 8 May 2023 20:26:15 +0530 Subject: [PATCH] fix(llc): fix cannot modify immutable list. Signed-off-by: xsahil03x --- .../stream_chat/lib/src/client/channel.dart | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index 1d419cbb..8152753d 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -997,26 +997,24 @@ class Channel { ) async { final type = reaction.type; - final reactionCounts = {...message.reactionCounts ?? {}}; + final reactionCounts = {...?message.reactionCounts}; if (reactionCounts.containsKey(type)) { reactionCounts.update(type, (value) => value - 1); } - final reactionScores = {...message.reactionScores ?? {}}; + final reactionScores = {...?message.reactionScores}; if (reactionScores.containsKey(type)) { reactionScores.update(type, (value) => value - 1); } - final latestReactions = [...message.latestReactions ?? []] - ..removeWhere((r) => - r.userId == reaction.userId && - r.type == reaction.type && - r.messageId == reaction.messageId); + final latestReactions = [...?message.latestReactions]..removeWhere((r) => + r.userId == reaction.userId && + r.type == reaction.type && + r.messageId == reaction.messageId); - final ownReactions = message.ownReactions - ?..removeWhere((r) => - r.userId == reaction.userId && - r.type == reaction.type && - r.messageId == reaction.messageId); + final ownReactions = [...?message.ownReactions]..removeWhere((r) => + r.userId == reaction.userId && + r.type == reaction.type && + r.messageId == reaction.messageId); final newMessage = message.copyWith( reactionCounts: reactionCounts..removeWhere((_, value) => value == 0),