fix reconnection event

This commit is contained in:
Salvatore Giordano
2022-03-23 09:59:24 +01:00
parent 5f12802799
commit 2c2b6bdac2
@@ -425,7 +425,8 @@ class StreamChatClient {
online: status == ConnectionStatus.connected,
));
if (currentState == ConnectionStatus.connected) {
if (currentState == ConnectionStatus.connected &&
previousState != ConnectionStatus.connected) {
// connection recovered
final cids = state.channels.keys.toList(growable: false);
if (cids.isNotEmpty) {
@@ -437,14 +438,12 @@ class StreamChatClient {
await sync(cids: cids, lastSyncAt: _lastSyncedAt);
}
}
if (previousState != ConnectionStatus.connected) {
handleEvent(Event(
type: EventType.connectionRecovered,
online: true,
));
}
}
}
/// Stream of [Event] coming from [_ws] connection
/// Pass an eventType as parameter in order to filter just a type of event