Merge pull request #7607 from thunderbird/saving_server_settings
Tweak `SaveServerSettingsScreen`
This commit is contained in:
commit
74654e0ea9
5 changed files with 5 additions and 57 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,
|
||||
),
|
||||
)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="account_edit_save_server_settings_loading_message">Saving server settings in progress</string>
|
||||
<string name="account_edit_save_server_settings_error_message">Saving server settings failed</string>
|
||||
<string name="account_edit_save_server_settings_success_message">Saving server settings was successful</string>
|
||||
<string name="account_edit_save_server_settings_loading_message">Saving server settings…</string>
|
||||
<string name="account_edit_save_server_settings_error_message">Failed to save server settings</string>
|
||||
<string name="account_edit_save_server_settings_success_message">Server settings saved</string>
|
||||
</resources>
|
||||
|
|
|
@ -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