fix removing message from thread

This commit is contained in:
Bartek Stoliński
2022-02-22 09:42:21 +01:00
parent 8d158ba1ac
commit e9626dc348
2 changed files with 15 additions and 5 deletions
+2
View File
@@ -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
@@ -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<String, List<Message>>.from(threads);
newThreads[parentId] = [
...newThreads[parentId]!
..removeWhere((e) => e.id == message.id),
];
_threads = newThreads;
return;
}
// Remove regular message