diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 82225b27..59feb777 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -10,6 +10,8 @@ - [[#890]](https://github.com/GetStream/stream-chat-flutter/pull/890) Fixed Reactions not updating on thread messages. Thanks [bstolinski](https://github.com/bstolinski). - [[#897]](https://github.com/GetStream/stream-chat-flutter/issues/897) Fixed error type mis-match in `AuthInterceptor`. +- [[#891]](https://github.com/GetStream/stream-chat-flutter/pull/891). Fixed reply counter for parent message not + updating correctly after deleting thread message. ## 3.4.0 diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index c27f3634..2b311061 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -1826,11 +1826,19 @@ class ChannelClientState { final parentId = message.parentId; // i.e. it's a thread message, Remove it if (parentId != null) { - final threadMessages = [...threads[parentId]!]; - return updateThreadInfo( - parentId, - threadMessages..removeWhere((e) => e.id == message.id), - ); + if (!threads.containsKey(parentId)) { + return; + } + + final newThreads = Map>.from(threads); + + newThreads[parentId] = [ + ...newThreads[parentId]! + ..removeWhere((e) => e.id == message.id), + ]; + + _threads = newThreads; + return; } // Remove regular message