feat: Fix WebSocket connection issues after account registration by ensuring connection before authentication
This commit is contained in:
@@ -175,7 +175,13 @@ class AuthStateManager(
|
||||
|
||||
loadAccounts()
|
||||
|
||||
// Step 8: Authenticate with protocol
|
||||
// Step 8: Connect and authenticate with protocol
|
||||
Log.d(TAG, "🌐 Connecting to protocol server...")
|
||||
ProtocolManager.connect()
|
||||
|
||||
// Give WebSocket time to connect before authenticating
|
||||
kotlinx.coroutines.delay(500)
|
||||
|
||||
Log.d(TAG, "🌐 Authenticating with protocol server...")
|
||||
ProtocolManager.authenticate(keyPair.publicKey, privateKeyHash)
|
||||
|
||||
@@ -236,7 +242,13 @@ class AuthStateManager(
|
||||
status = AuthStatus.Authenticated(decryptedAccount)
|
||||
)}
|
||||
|
||||
// Authenticate with protocol
|
||||
// Connect and authenticate with protocol
|
||||
Log.d(TAG, "🌐 Connecting to protocol server...")
|
||||
ProtocolManager.connect()
|
||||
|
||||
// Give WebSocket time to connect before authenticating
|
||||
kotlinx.coroutines.delay(500)
|
||||
|
||||
Log.d(TAG, "🌐 Authenticating with protocol server...")
|
||||
ProtocolManager.authenticate(decryptedAccount.publicKey, decryptedAccount.privateKeyHash)
|
||||
|
||||
|
||||
@@ -497,6 +497,9 @@ fun SetPasswordScreen(
|
||||
// 🔌 Connect to server and authenticate
|
||||
val privateKeyHash = CryptoManager.generatePrivateKeyHash(keyPair.privateKey)
|
||||
Log.d("SetPasswordScreen", "🔌 Connecting to server...")
|
||||
ProtocolManager.connect()
|
||||
// Give WebSocket time to connect before authenticating
|
||||
kotlinx.coroutines.delay(500)
|
||||
ProtocolManager.authenticate(keyPair.publicKey, privateKeyHash)
|
||||
|
||||
onAccountCreated()
|
||||
|
||||
@@ -581,6 +581,9 @@ fun UnlockScreen(
|
||||
|
||||
// Connect to server and authenticate
|
||||
Log.d("UnlockScreen", "Connecting to server...")
|
||||
ProtocolManager.connect()
|
||||
// Give WebSocket time to connect before authenticating
|
||||
kotlinx.coroutines.delay(500)
|
||||
ProtocolManager.authenticate(account.publicKey, privateKeyHash)
|
||||
|
||||
accountManager.setCurrentAccount(account.publicKey)
|
||||
|
||||
Reference in New Issue
Block a user