refactor: enhance push notification routing with full payload handling and add socket connection state management
This commit is contained in:
@@ -59,8 +59,23 @@ class SocketService {
|
||||
return;
|
||||
}
|
||||
|
||||
// Already fully connected with the same token — no-op.
|
||||
if (_socket?.connected == true && _currentToken == token) return;
|
||||
|
||||
// A socket already exists for this same token but isn't connected yet
|
||||
// (either in-flight or temporarily disconnected). Don't dispose and
|
||||
// recreate — that kills the in-flight attempt and causes a race when
|
||||
// `connect()` is called twice in quick succession (e.g. once from the
|
||||
// auth provider on app launch and once from chat_screen's
|
||||
// ensureConnected() after a notification tap). Just kick it to connect.
|
||||
if (_socket != null && _currentToken == token) {
|
||||
_intentionalDisconnect = false;
|
||||
if (_socket!.connected != true) {
|
||||
_socket!.connect();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
_currentToken = token;
|
||||
_intentionalDisconnect = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user