Merge branch 'develop' into develop
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
## Upcoming
|
||||
|
||||
🐞 Fixed
|
||||
|
||||
- [[#1585]](https://github.com/GetStream/stream-chat-flutter/issues/1585) Fixed channels left not being removed from
|
||||
the persistent storage.
|
||||
|
||||
🔄 Changed
|
||||
|
||||
- Updated `dio` dependency to `^5.2.0`.
|
||||
|
||||
@@ -1576,6 +1576,8 @@ class ClientState {
|
||||
currentUser = currentUser?.copyWith(totalUnreadCount: count);
|
||||
}));
|
||||
|
||||
_listenChannelLeft();
|
||||
|
||||
_listenChannelDeleted();
|
||||
|
||||
_listenChannelHidden();
|
||||
@@ -1636,12 +1638,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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user