Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update NativeVaultManager.kt to offload register credentials in background task (#520)
Leendert de Borstea4d72cecadb
diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.ktindex 0198aa1b4..b4b3f02e2 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.kt@@ -1011,33 +1011,36 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :/*** Register credential identities in the Native Autofill API cache.* This stores passkey metadata so they can be shown without unlocking the vault.+ * Runs asynchronously to avoid blocking the UI thread.* @param promise The promise to resolve.*/@ReactMethodoverride fun registerCredentialIdentities(promise: Promise) {- try {- // Get all credentials from the vault- val credentials = vaultStore.getAllCredentials()-- // Get database connection- val db = vaultStore.database- if (db == null) {- Log.w(TAG, "Database not available - vault may be locked")- promise.resolve(null)- return- }+ // Resolve promise immediately to avoid blocking navigation+ promise.resolve(null)- // Save credential identities to the identity store- val identityStore = net.aliasvault.app.credentialprovider.CredentialIdentityStore.getInstance(- reactApplicationContext,- )- identityStore.saveCredentialIdentities(credentials, vaultStore, db)+ // Execute registration in background thread+ Thread {+ try {+ // Get all credentials from the vault+ val credentials = vaultStore.getAllCredentials()++ // Get database connection+ val db = vaultStore.database+ if (db == null) {+ Log.w(TAG, "Database not available - vault may be locked")+ return@Thread+ }- promise.resolve(null)- } catch (e: Exception) {- Log.e(TAG, "Error registering credential identities", e)- promise.reject("ERR_REGISTER_IDENTITIES", "Failed to register credential identities: ${e.message}", e)- }+ // Save credential identities to the identity store+ val identityStore = net.aliasvault.app.credentialprovider.CredentialIdentityStore.getInstance(+ reactApplicationContext,+ )+ identityStore.saveCredentialIdentities(credentials, vaultStore, db)+ } catch (e: Exception) {+ Log.e(TAG, "Error registering credential identities in background", e)+ }+ }.start()}// MARK: - Username Management