Fixed ghost channel subscription
This commit is contained in:
@@ -329,12 +329,22 @@ class StreamRecoveryWrapper<T> {
|
||||
_startRealtimeSubscription();
|
||||
}
|
||||
|
||||
/// Clean up all resources.
|
||||
/// Clean up all resources and notify the status callback that this
|
||||
/// channel is no longer active, preventing ghost entries in the
|
||||
/// [RealtimeController]'s recovering-channels set.
|
||||
void dispose() {
|
||||
if (_disposed) return;
|
||||
_disposed = true;
|
||||
_pollingTimer?.cancel();
|
||||
_recoveryTimer?.cancel();
|
||||
_realtimeSub?.cancel();
|
||||
// Ensure the channel is removed from the recovering set when the
|
||||
// wrapper is torn down (e.g. provider disposed during navigation).
|
||||
// Without this, disposed wrappers that were mid-recovery leave
|
||||
// orphaned entries that keep the reconnection indicator spinning.
|
||||
if (_connectionStatus != StreamConnectionStatus.connected) {
|
||||
_onStatusChanged?.call(channelName, StreamConnectionStatus.connected);
|
||||
}
|
||||
_controller?.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user