From e5a1a74f072735778bd3ad192e442bb06c6a5775 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Wed, 1 Dec 2021 01:10:18 +0530 Subject: [PATCH] chore(llc): add index check in unreadCount setter. Signed-off-by: xsahil03x --- packages/stream_chat/lib/src/client/channel.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index af0703f2..657b8617 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -1860,6 +1860,9 @@ class ChannelClientState { set unreadCount(int count) { final reads = [..._channelState.read]; final currentUserReadIndex = reads.indexWhere(_isCurrentUserRead); + + if (currentUserReadIndex < 0) return; + reads[currentUserReadIndex] = reads[currentUserReadIndex].copyWith(unreadMessages: count); _channelState = _channelState.copyWith(read: reads);