fix(llc): Error while hiding channel and clearing message history.

Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2023-05-02 18:51:29 +05:30
committed by xsahil03x
parent 53baa5a574
commit 2bd8defe6d
3 changed files with 10 additions and 13 deletions
+5
View File
@@ -1,5 +1,10 @@
## Upcoming ## Upcoming
🐞 Fixed
- [[#1355]](https://github.com/GetStream/stream-chat-flutter/issues/1355) Fixed error while hiding channel and clearing
message history.
✅ Added ✅ Added
- Expose `ChannelMute` class. [#1473](https://github.com/GetStream/stream-chat-flutter/issues/1473) - Expose `ChannelMute` class. [#1473](https://github.com/GetStream/stream-chat-flutter/issues/1473)
@@ -1485,19 +1485,11 @@ class Channel {
/// will be removed for the user. /// will be removed for the user.
Future<EmptyResponse> hide({bool clearHistory = false}) async { Future<EmptyResponse> hide({bool clearHistory = false}) async {
_checkInitialized(); _checkInitialized();
final response = await _client.hideChannel( return _client.hideChannel(
id!, id!,
type, type,
clearHistory: clearHistory, clearHistory: clearHistory,
); );
if (clearHistory) {
state!.truncate();
final cid = _cid;
if (cid != null) {
await _client.chatPersistenceClient?.deleteMessageByCid(cid);
}
}
return response;
} }
/// Removes the hidden status for the channel. /// Removes the hidden status for the channel.
@@ -1567,7 +1567,7 @@ class ClientState {
_client.on(EventType.channelHidden).listen((event) async { _client.on(EventType.channelHidden).listen((event) async {
final eventChannel = event.channel!; final eventChannel = event.channel!;
await _client.chatPersistenceClient?.deleteChannels([eventChannel.cid]); await _client.chatPersistenceClient?.deleteChannels([eventChannel.cid]);
channels[eventChannel.cid]?.dispose(); channels.remove(eventChannel.cid)?.dispose();
}), }),
); );
} }
@@ -1606,7 +1606,7 @@ class ClientState {
.listen((Event event) async { .listen((Event event) async {
final eventChannel = event.channel!; final eventChannel = event.channel!;
await _client.chatPersistenceClient?.deleteChannels([eventChannel.cid]); await _client.chatPersistenceClient?.deleteChannels([eventChannel.cid]);
channels[eventChannel.cid]?.dispose(); channels.remove(eventChannel.cid)?.dispose();
}), }),
); );
} }
@@ -1713,9 +1713,9 @@ class ClientState {
_unreadChannelsController.close(); _unreadChannelsController.close();
_totalUnreadCountController.close(); _totalUnreadCountController.close();
final channels = this.channels.values.toList(); final channels = this.channels.keys;
for (final channel in channels) { for (final channel in channels) {
channel.dispose(); this.channels.remove(channel)?.dispose();
} }
_channelsController.close(); _channelsController.close();
} }