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, online: status == ConnectionStatus.connected,
)); ));
if (currentState == ConnectionStatus.connected) { if (currentState == ConnectionStatus.connected &&
previousState != ConnectionStatus.connected) {
// connection recovered // connection recovered
final cids = state.channels.keys.toList(growable: false); final cids = state.channels.keys.toList(growable: false);
if (cids.isNotEmpty) { if (cids.isNotEmpty) {
@@ -437,14 +438,12 @@ class StreamChatClient {
await sync(cids: cids, lastSyncAt: _lastSyncedAt); await sync(cids: cids, lastSyncAt: _lastSyncedAt);
} }
} }
if (previousState != ConnectionStatus.connected) {
handleEvent(Event( handleEvent(Event(
type: EventType.connectionRecovered, type: EventType.connectionRecovered,
online: true, online: true,
)); ));
} }
} }
}
/// Stream of [Event] coming from [_ws] connection /// Stream of [Event] coming from [_ws] connection
/// Pass an eventType as parameter in order to filter just a type of event /// Pass an eventType as parameter in order to filter just a type of event