Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ohassine committed Jun 14, 2024
1 parent aec99d3 commit dad118e
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions app/src/main/kotlin/com/wire/android/ui/WireActivityViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ class WireActivityViewModel @Inject constructor(
val shouldLogin = viewModelScope.async(dispatchers.io()) {
shouldLogIn()
}
val shouldEnrollToE2ei = shouldEnrollToE2ei().await()
val shouldEnrollToE2ei = shouldEnrollToE2ei()
return when {
shouldMigrate.await() -> InitialAppState.NOT_MIGRATED
shouldLogin.await() -> InitialAppState.NOT_LOGGED_IN
shouldEnrollToE2ei -> InitialAppState.ENROLL_E2EI
shouldEnrollToE2ei.await() -> InitialAppState.ENROLL_E2EI
else -> InitialAppState.LOGGED_IN
}
}
Expand Down Expand Up @@ -506,17 +506,15 @@ class WireActivityViewModel @Inject constructor(
globalAppState = globalAppState.copy(conversationJoinedDialog = null)
}

private suspend fun shouldLogIn(): Boolean = !hasValidCurrentSession().await()
private suspend fun shouldLogIn(): Boolean = !hasValidCurrentSession()

private fun hasValidCurrentSession(): Deferred<Boolean> =
viewModelScope.async(dispatchers.io()) {
// TODO: the usage of currentSessionFlow is a temporary solution, it should be replaced with a proper solution
currentSessionFlow.get().invoke().first().let {
when (it) {
is CurrentSessionResult.Failure.Generic -> false
CurrentSessionResult.Failure.SessionNotFound -> false
is CurrentSessionResult.Success -> true
}
private suspend fun hasValidCurrentSession(): Boolean =
// TODO: the usage of currentSessionFlow is a temporary solution, it should be replaced with a proper solution
currentSessionFlow.get().invoke().first().let {
when (it) {
is CurrentSessionResult.Failure.Generic -> false
CurrentSessionResult.Failure.SessionNotFound -> false
is CurrentSessionResult.Success -> true
}
}

Expand Down

0 comments on commit dad118e

Please sign in to comment.