Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 7da66f18 authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé Committed by GitHub
Browse files

Merge pull request #7105 from thundernest/fix_timer_based_navigation

Fix timer based navigation
parents d7a9ff14 303a8f94
Loading
Loading
Loading
Loading
+7 −16
Original line number Diff line number Diff line
@@ -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,22 +110,8 @@ 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()
    }
    }

    private fun onRetry() {
        updateState {
@@ -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)
    }
}
+0 −32
Original line number Diff line number Diff line
@@ -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(