remove nullability

This commit is contained in:
Hugh Nimmo-Smith 2022-10-17 17:36:35 +01:00
parent 8f4d998362
commit 6d17d51fe9
2 changed files with 12 additions and 14 deletions

View File

@ -89,7 +89,7 @@ class Rendezvous(
}
@Throws(RendezvousError::class)
suspend fun startAfterScanningCode(): String? {
suspend fun startAfterScanningCode(): String {
val checksum = channel.connect()
Timber.tag(TAG).i("Connected to secure channel with checksum: $checksum")
@ -111,7 +111,7 @@ class Rendezvous(
}
@Throws(RendezvousError::class)
suspend fun waitForLoginOnNewDevice(authenticationService: AuthenticationService): Session? {
suspend fun waitForLoginOnNewDevice(authenticationService: AuthenticationService): Session {
Timber.tag(TAG).i("Waiting for login_token")
val loginToken = receive()

View File

@ -100,21 +100,19 @@ class QrCodeLoginViewModel @AssistedInject constructor(
try {
val confirmationCode = rendezvous.startAfterScanningCode()
Timber.tag(TAG).i("Established secure channel with checksum: $confirmationCode")
confirmationCode?.let {
onConnectionEstablished(it)
val session = rendezvous.waitForLoginOnNewDevice(authenticationService)
onSigningIn()
session?.let {
activeSessionHolder.setActiveSession(session)
authenticationService.reset()
configureAndStartSessionUseCase.execute(session)
onConnectionEstablished(confirmationCode)
rendezvous.completeVerificationOnNewDevice(session)
val session = rendezvous.waitForLoginOnNewDevice(authenticationService)
onSigningIn()
_viewEvents.post(QrCodeLoginViewEvents.NavigateToHomeScreen)
}
}
activeSessionHolder.setActiveSession(session)
authenticationService.reset()
configureAndStartSessionUseCase.execute(session)
rendezvous.completeVerificationOnNewDevice(session)
_viewEvents.post(QrCodeLoginViewEvents.NavigateToHomeScreen)
} catch (t: Throwable) {
Timber.tag(TAG).e(t, "Error occurred during sign in")
if (t is RendezvousError) {