Skip to content

Commit

Permalink
Merge pull request #3140 from element-hq/feature/fga/fix_npe_on_verif…
Browse files Browse the repository at this point in the history
…ication_service

Bugfix : avoid potential NPE on verification service.
  • Loading branch information
ganfra authored Jul 4, 2024
2 parents cc090b0 + c8a01e3 commit d9d5a06
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ class RustSessionVerificationService(
private val encryptionService: Encryption = client.encryption()
private lateinit var verificationController: SessionVerificationController

private val _verificationFlowState = MutableStateFlow<VerificationFlowState>(VerificationFlowState.Initial)
override val verificationFlowState = _verificationFlowState.asStateFlow()

private val _sessionVerifiedStatus = MutableStateFlow<SessionVerifiedStatus>(SessionVerifiedStatus.Unknown)
override val sessionVerifiedStatus: StateFlow<SessionVerifiedStatus> = _sessionVerifiedStatus.asStateFlow()

// Listen for changes in verification status and update accordingly
private val verificationStateListenerTaskHandle = encryptionService.verificationStateListener(object : VerificationStateListener {
override fun onUpdate(status: VerificationState) {
Expand All @@ -74,12 +80,6 @@ class RustSessionVerificationService(
}
})

private val _verificationFlowState = MutableStateFlow<VerificationFlowState>(VerificationFlowState.Initial)
override val verificationFlowState = _verificationFlowState.asStateFlow()

private val _sessionVerifiedStatus = MutableStateFlow<SessionVerifiedStatus>(SessionVerifiedStatus.Unknown)
override val sessionVerifiedStatus: StateFlow<SessionVerifiedStatus> = _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.
Expand Down

0 comments on commit d9d5a06

Please sign in to comment.