From c8a01e38f178915b3bbc19a58e5befff1b8e6dec Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 4 Jul 2024 14:51:14 +0200 Subject: [PATCH] Bugfix : avoid potential NPE on verification service. --- .../verification/RustSessionVerificationService.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 95ae68de44..3c3aeb7bcb 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 @@ -57,6 +57,12 @@ class RustSessionVerificationService( private val encryptionService: Encryption = client.encryption() private lateinit var verificationController: SessionVerificationController + private val _verificationFlowState = MutableStateFlow(VerificationFlowState.Initial) + override val verificationFlowState = _verificationFlowState.asStateFlow() + + private val _sessionVerifiedStatus = MutableStateFlow(SessionVerifiedStatus.Unknown) + override val sessionVerifiedStatus: StateFlow = _sessionVerifiedStatus.asStateFlow() + // Listen for changes in verification status and update accordingly private val verificationStateListenerTaskHandle = encryptionService.verificationStateListener(object : VerificationStateListener { override fun onUpdate(status: VerificationState) { @@ -74,12 +80,6 @@ class RustSessionVerificationService( } }) - private val _verificationFlowState = MutableStateFlow(VerificationFlowState.Initial) - override val verificationFlowState = _verificationFlowState.asStateFlow() - - private val _sessionVerifiedStatus = MutableStateFlow(SessionVerifiedStatus.Unknown) - override val sessionVerifiedStatus: StateFlow = _sessionVerifiedStatus.asStateFlow() - /** * The internal service that checks verification can only run after the initial sync. * This [StateFlow] will notify consumers when the service is ready to be used.