fix(llc): Remove cached channel once left.

Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2023-06-05 16:55:41 +05:30
committed by xsahil03x
parent c307ee86f9
commit 8978cb0035
2 changed files with 23 additions and 3 deletions
@@ -1541,6 +1541,8 @@ class ClientState {
currentUser = currentUser?.copyWith(totalUnreadCount: count);
}));
_listenChannelLeft();
_listenChannelDeleted();
_listenChannelHidden();
@@ -1601,12 +1603,30 @@ class ClientState {
);
}
void _listenChannelLeft() {
_eventsSubscription?.add(
_client
.on(
EventType.memberRemoved,
EventType.notificationRemovedFromChannel,
)
.listen((event) async {
final isCurrentUser = event.user!.id == currentUser!.id;
if (isCurrentUser) {
final eventChannel = event.channel!;
await _client.chatPersistenceClient
?.deleteChannels([eventChannel.cid]);
channels.remove(eventChannel.cid)?.dispose();
}
}),
);
}
void _listenChannelDeleted() {
_eventsSubscription?.add(
_client
.on(
EventType.channelDeleted,
EventType.notificationRemovedFromChannel,
EventType.notificationChannelDeleted,
)
.listen((Event event) async {
+2 -2
View File
@@ -63,7 +63,7 @@ class EventType {
static const String notificationAddedToChannel =
'notification.added_to_channel';
/// Event sent when the user is removed to a channel
/// Event sent when the user is removed from a channel
static const String notificationRemovedFromChannel =
'notification.removed_from_channel';
@@ -76,7 +76,7 @@ class EventType {
/// Event sent when a member is added to a channel
static const String memberAdded = 'member.added';
/// Event sent when a member is removed to a channel
/// Event sent when a member is removed from a channel
static const String memberRemoved = 'member.removed';
/// Event sent when a member is updated in a channel