From 7f7612ef12cc5b27d644d4d10e770ef6254707c1 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 18 Sep 2024 14:14:10 +0200 Subject: [PATCH] Code cleanup --- .../auth/RustMatrixAuthenticationService.kt | 27 +++++++++---------- .../RustSessionVerificationService.kt | 1 + 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationService.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationService.kt index d1f0d29295..b63e307888 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationService.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationService.kt @@ -251,18 +251,17 @@ class RustMatrixAuthenticationService @Inject constructor( oidcConfiguration = oidcConfiguration, progressListener = progressListener, ) - - client.use { rustClient -> - val sessionData = rustClient.session() + val sessionData = client.use { rustClient -> + rustClient.session() .toSessionData( isTokenValid = true, loginType = LoginType.QR, passphrase = pendingPassphrase, sessionPaths = emptySessionPaths, ) - sessionStore.storeData(sessionData) - SessionId(sessionData.userId) } + sessionStore.storeData(sessionData) + SessionId(sessionData.userId) }.mapFailure { when (it) { is QrCodeDecodeException -> QrErrorMapper.map(it) @@ -285,14 +284,14 @@ class RustMatrixAuthenticationService @Inject constructor( if (slidingSyncType is ClientBuilderSlidingSync.Simplified) { Timber.d("Creating client with simplified sliding sync") try { - return rustMatrixClientFactory - .getBaseClientBuilder( - sessionPaths = sessionPaths, - passphrase = pendingPassphrase, - slidingSyncType = slidingSyncType, - ) - .run { config() } - .build() + return rustMatrixClientFactory + .getBaseClientBuilder( + sessionPaths = sessionPaths, + passphrase = pendingPassphrase, + slidingSyncType = slidingSyncType, + ) + .config() + .build() } catch (e: HumanQrLoginException.SlidingSyncNotAvailable) { Timber.e(e, "Failed to create client with simplified sliding sync, trying with Proxy now") } @@ -304,7 +303,7 @@ class RustMatrixAuthenticationService @Inject constructor( passphrase = pendingPassphrase, slidingSyncType = getSlidingSyncProxy(), ) - .run { config() } + .config() .build() } diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/verification/RustSessionVerificationService.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/verification/RustSessionVerificationService.kt index 9d55d3402c..71004a74d7 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/verification/RustSessionVerificationService.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/verification/RustSessionVerificationService.kt @@ -206,6 +206,7 @@ class RustSessionVerificationService( } } } + private suspend fun updateVerificationStatus() { if (verificationFlowState.value == VerificationFlowState.Finished) { // Calling `encryptionService.verificationState()` performs a network call and it will deadlock if there is no network