From 674932695f61323346d96ef65bc909f2561ec1c9 Mon Sep 17 00:00:00 2001 From: cketti Date: Tue, 19 Dec 2023 21:30:41 +0100 Subject: [PATCH] Don't delay when user clicks 'Next' in special folders screen --- .../ui/specialfolders/SpecialFoldersViewModel.kt | 14 +++++++------- .../specialfolders/SpecialFoldersViewModelTest.kt | 4 +--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/specialfolders/SpecialFoldersViewModel.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/specialfolders/SpecialFoldersViewModel.kt index 32710c763..3a6e7ab3a 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/specialfolders/SpecialFoldersViewModel.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/specialfolders/SpecialFoldersViewModel.kt @@ -77,7 +77,11 @@ class SpecialFoldersViewModel( isSuccess = true, ) } + saveSpecialFolderSettings() + + delay(CONTINUE_NEXT_DELAY) + navigateNext() } } } @@ -99,7 +103,7 @@ class SpecialFoldersViewModel( } } - private suspend fun saveSpecialFolderSettings() { + private fun saveSpecialFolderSettings() { val formState = state.value.formState accountStateRepository.setSpecialFolderSettings( @@ -116,15 +120,11 @@ class SpecialFoldersViewModel( isLoading = false, ) } - - delay(CONTINUE_NEXT_DELAY) - navigateNext() } private fun onNextClicked() { - viewModelScope.launch { - saveSpecialFolderSettings() - } + saveSpecialFolderSettings() + navigateNext() } private fun navigateNext() { diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/specialfolders/SpecialFoldersViewModelTest.kt b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/specialfolders/SpecialFoldersViewModelTest.kt index 601ba1839..50e9a2308 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/specialfolders/SpecialFoldersViewModelTest.kt +++ b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/specialfolders/SpecialFoldersViewModelTest.kt @@ -197,9 +197,7 @@ class SpecialFoldersViewModelTest { testSubject.event(Event.OnNextClicked) - turbines.assertThatAndStateTurbineConsumed { - isEqualTo(initialState.copy(isLoading = false)) - } + assertThat(turbines.awaitStateItem()).isEqualTo(initialState.copy(isLoading = false)) turbines.assertThatAndEffectTurbineConsumed { isEqualTo(Effect.NavigateNext)