Don't show "next" button when saving server settings
This commit is contained in:
parent
a8c6391da9
commit
8f8c22e616
4 changed files with 2 additions and 54 deletions
|
@ -24,7 +24,6 @@ abstract class BaseSaveServerSettingsViewModel(
|
|||
override fun event(event: Event) {
|
||||
when (event) {
|
||||
Event.SaveServerSettings -> handleOneTimeEvent(event, ::onSaveServerSettings)
|
||||
Event.OnNextClicked -> navigateNext()
|
||||
Event.OnBackClicked -> navigateBack()
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +63,6 @@ abstract class BaseSaveServerSettingsViewModel(
|
|||
}
|
||||
|
||||
private fun navigateNext() {
|
||||
if (state.value.isLoading || state.value.error != null) return
|
||||
|
||||
viewModelScope.coroutineContext.cancelChildren()
|
||||
emitEffect(Effect.NavigateNext)
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ interface SaveServerSettingsContract {
|
|||
|
||||
sealed interface Event {
|
||||
data object SaveServerSettings : Event
|
||||
data object OnNextClicked : Event
|
||||
data object OnBackClicked : Event
|
||||
}
|
||||
|
||||
|
|
|
@ -51,14 +51,12 @@ fun SaveServerSettingsScreen(
|
|||
},
|
||||
bottomBar = {
|
||||
WizardNavigationBar(
|
||||
onNextClick = {
|
||||
dispatch(Event.OnNextClicked)
|
||||
},
|
||||
onNextClick = {},
|
||||
onBackClick = {
|
||||
dispatch(Event.OnBackClicked)
|
||||
},
|
||||
state = WizardNavigationBarState(
|
||||
isNextEnabled = state.value.error == null && !state.value.isLoading,
|
||||
showNext = false,
|
||||
isBackEnabled = state.value.error != null,
|
||||
),
|
||||
)
|
||||
|
|
|
@ -70,48 +70,6 @@ class BaseSaveServerSettingsViewModelTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should prevent navigation effects when in loading state`() = runTest {
|
||||
val testSubject = TestSaveServerSettingsViewModel(
|
||||
accountUuid = ACCOUNT_UUID,
|
||||
saveServerSettings = { _, _ ->
|
||||
// Do nothing
|
||||
},
|
||||
initialState = State(isLoading = true),
|
||||
)
|
||||
val turbines = turbinesWithInitialStateCheck(testSubject, State(isLoading = true))
|
||||
|
||||
testSubject.event(Event.OnNextClicked)
|
||||
|
||||
turbines.effectTurbine.ensureAllEventsConsumed()
|
||||
|
||||
testSubject.event(Event.OnBackClicked)
|
||||
|
||||
turbines.effectTurbine.ensureAllEventsConsumed()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should allow NavigateNext when no error and not loading`() = runTest {
|
||||
val testSubject = TestSaveServerSettingsViewModel(
|
||||
accountUuid = ACCOUNT_UUID,
|
||||
saveServerSettings = { _, _ ->
|
||||
// Do nothing
|
||||
},
|
||||
initialState = State(isLoading = false),
|
||||
)
|
||||
val turbines = turbinesWithInitialStateCheck(testSubject, State(isLoading = false))
|
||||
|
||||
testSubject.event(Event.OnNextClicked)
|
||||
|
||||
turbines.assertThatAndEffectTurbineConsumed {
|
||||
isEqualTo(Effect.NavigateNext)
|
||||
}
|
||||
|
||||
testSubject.event(Event.OnBackClicked)
|
||||
|
||||
turbines.effectTurbine.ensureAllEventsConsumed()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should allow NavigateBack when error and not loading`() = runTest {
|
||||
val failure = Failure.SaveServerSettingsFailed("Test exception")
|
||||
|
@ -127,10 +85,6 @@ class BaseSaveServerSettingsViewModelTest {
|
|||
)
|
||||
val turbines = turbinesWithInitialStateCheck(testSubject, State(isLoading = false, error = failure))
|
||||
|
||||
testSubject.event(Event.OnNextClicked)
|
||||
|
||||
turbines.effectTurbine.ensureAllEventsConsumed()
|
||||
|
||||
testSubject.event(Event.OnBackClicked)
|
||||
|
||||
turbines.assertThatAndEffectTurbineConsumed {
|
||||
|
|
Loading…
Reference in a new issue