Merge pull request #7105 from thundernest/fix_timer_based_navigation
Fix timer based navigation
This commit is contained in:
commit
7da66f1867
2 changed files with 7 additions and 48 deletions
|
@ -8,6 +8,7 @@ import app.k9mail.feature.account.setup.ui.validation.AccountValidationContract.
|
|||
import app.k9mail.feature.account.setup.ui.validation.AccountValidationContract.Event
|
||||
import app.k9mail.feature.account.setup.ui.validation.AccountValidationContract.State
|
||||
import com.fsck.k9.mail.server.ServerSettingsValidationResult
|
||||
import kotlinx.coroutines.cancelChildren
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
@ -109,21 +110,7 @@ internal class AccountValidationViewModel(
|
|||
}
|
||||
|
||||
private fun onBack() {
|
||||
if (state.value.isSuccess) {
|
||||
updateState {
|
||||
it.copy(
|
||||
isSuccess = false,
|
||||
)
|
||||
}
|
||||
} else if (state.value.error != null) {
|
||||
updateState {
|
||||
it.copy(
|
||||
error = null,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
navigateBack()
|
||||
}
|
||||
navigateBack()
|
||||
}
|
||||
|
||||
private fun onRetry() {
|
||||
|
@ -135,9 +122,13 @@ internal class AccountValidationViewModel(
|
|||
onValidateConfig()
|
||||
}
|
||||
|
||||
private fun navigateBack() = emitEffect(Effect.NavigateBack)
|
||||
private fun navigateBack() {
|
||||
viewModelScope.coroutineContext.cancelChildren()
|
||||
emitEffect(Effect.NavigateBack)
|
||||
}
|
||||
|
||||
private fun navigateNext() {
|
||||
viewModelScope.coroutineContext.cancelChildren()
|
||||
emitEffect(Effect.NavigateNext)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,38 +163,6 @@ class AccountValidationViewModelTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should clear isSuccess when OnBackClicked event received when in success state`() = runTest {
|
||||
val initialState = State(isSuccess = true)
|
||||
val testSubject = createTestSubject(initialState = initialState)
|
||||
val turbines = turbinesWithInitialStateCheck(testSubject, initialState)
|
||||
|
||||
testSubject.event(Event.OnBackClicked)
|
||||
|
||||
assertThatAndMviTurbinesConsumed(
|
||||
actual = turbines.stateTurbine.awaitItem(),
|
||||
turbines = turbines,
|
||||
) {
|
||||
isEqualTo(initialState.copy(isSuccess = false))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should clear error when OnBackClicked event received when in error state`() = runTest {
|
||||
val initialState = State(error = Error.ServerError("server error"))
|
||||
val testSubject = createTestSubject(initialState = initialState)
|
||||
val turbines = turbinesWithInitialStateCheck(testSubject, initialState)
|
||||
|
||||
testSubject.event(Event.OnBackClicked)
|
||||
|
||||
assertThatAndMviTurbinesConsumed(
|
||||
actual = turbines.stateTurbine.awaitItem(),
|
||||
turbines = turbines,
|
||||
) {
|
||||
isEqualTo(initialState.copy(error = null))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should clear error and trigger check settings when OnRetryClicked event received`() = runTest {
|
||||
val initialState = State(
|
||||
|
|
Loading…
Reference in a new issue