diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 0cfcf586..84b57f16 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -17,6 +17,8 @@ any channel. - [[#1047]](https://github.com/GetStream/stream-chat-flutter/issues/1047) `own_capabilities` extraData missing after channel update. +- [[#1054]](https://github.com/GetStream/stream-chat-flutter/issues/1054) Fix `Unsupported operation: Cannot remove from an unmodifiable list`. +- [[#1033]](https://github.com/GetStream/stream-chat-flutter/issues/1033) Hard delete from dashboard does not delete message from client. ✅ Added diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index 1f97a14a..0c3a6620 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -1116,7 +1116,6 @@ class Channel { // remove the passed message if response does // not contain message state!.removeMessage(message); - await _client.chatPersistenceClient?.deleteMessageById(messageId); } return res; } @@ -1608,10 +1607,12 @@ class ChannelClientState { _subscriptions.add(_channel.on(EventType.memberRemoved).listen((Event e) { final user = e.user; updateChannelState(channelState.copyWith( - members: List.from( - channelState.members..removeWhere((m) => m.userId == user!.id), - ), - read: channelState.read..removeWhere((r) => r.user.id == user!.id), + members: channelState.members + .where((m) => m.userId != user!.id) + .toList(growable: false), + read: channelState.read + .where((r) => r.user.id != user!.id) + .toList(growable: false), )); })); } @@ -1871,7 +1872,9 @@ class ChannelClientState { } /// Remove a [message] from this [channelState]. - void removeMessage(Message message) { + void removeMessage(Message message) async { + await _channel._client.chatPersistenceClient?.deleteMessageById(message.id); + final parentId = message.parentId; // i.e. it's a thread message, Remove it if (parentId != null) {