feat: Implement optimistic UI for agent availability toggle, add email and phone visibility toggles, and improve the logout process with immediate socket disconnection and best-effort API calls.

This commit is contained in:
pradeepkumar
2026-03-15 00:35:39 +05:30
parent 54fdd66270
commit 21f669fca5
6 changed files with 104 additions and 14 deletions

View File

@@ -18,6 +18,7 @@ class SocketService {
io.Socket? _socket;
bool _isConnected = false;
bool _intentionalDisconnect = false;
String? _currentToken;
// Stream controllers for events
@@ -52,6 +53,7 @@ class SocketService {
if (_socket?.connected == true && _currentToken == token) return;
_currentToken = token;
_intentionalDisconnect = false;
// Strip /api/v1 from base URL for socket connection
final apiUrl = AppConfig.apiBaseUrl;
@@ -82,7 +84,7 @@ class SocketService {
_isConnected = false;
_connectionController.add(false);
if (reason == 'io server disconnect') {
if (reason == 'io server disconnect' && !_intentionalDisconnect) {
_log.w('Server rejected connection - token likely expired');
_reconnectWithFreshToken();
}
@@ -151,6 +153,7 @@ class SocketService {
}
void disconnect() {
_intentionalDisconnect = true;
_socket?.disconnect();
_socket?.dispose();
_socket = null;