diff --git a/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/data/InMemoryAccountStateRepository.kt b/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/data/InMemoryAccountStateRepository.kt index 3a8c245bb67..7cd368faffe 100644 --- a/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/data/InMemoryAccountStateRepository.kt +++ b/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/data/InMemoryAccountStateRepository.kt @@ -15,27 +15,27 @@ class InMemoryAccountStateRepository( return state } - override fun save(accountState: AccountState) { + override fun setState(accountState: AccountState) { state = accountState } - override fun saveEmailAddress(emailAddress: String) { + override fun setEmailAddress(emailAddress: String) { state = state.copy(emailAddress = emailAddress) } - override fun saveIncomingServerSettings(serverSettings: ServerSettings) { + override fun setIncomingServerSettings(serverSettings: ServerSettings) { state = state.copy(incomingServerSettings = serverSettings) } - override fun saveOutgoingServerSettings(serverSettings: ServerSettings) { + override fun setOutgoingServerSettings(serverSettings: ServerSettings) { state = state.copy(outgoingServerSettings = serverSettings) } - override fun saveAuthorizationState(authorizationState: AuthorizationState) { + override fun setAuthorizationState(authorizationState: AuthorizationState) { state = state.copy(authorizationState = authorizationState) } - override fun saveOptions(options: AccountOptions) { + override fun setOptions(options: AccountOptions) { state = state.copy(options = options) } diff --git a/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/domain/AccountDomainContract.kt b/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/domain/AccountDomainContract.kt index 1fd0fe7f427..4d325904b28 100644 --- a/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/domain/AccountDomainContract.kt +++ b/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/domain/AccountDomainContract.kt @@ -10,17 +10,17 @@ interface AccountDomainContract { interface AccountStateRepository { fun getState(): AccountState - fun save(accountState: AccountState) + fun setState(accountState: AccountState) - fun saveEmailAddress(emailAddress: String) + fun setEmailAddress(emailAddress: String) - fun saveIncomingServerSettings(serverSettings: ServerSettings) + fun setIncomingServerSettings(serverSettings: ServerSettings) - fun saveOutgoingServerSettings(serverSettings: ServerSettings) + fun setOutgoingServerSettings(serverSettings: ServerSettings) - fun saveAuthorizationState(authorizationState: AuthorizationState) + fun setAuthorizationState(authorizationState: AuthorizationState) - fun saveOptions(options: AccountOptions) + fun setOptions(options: AccountOptions) fun clear() } diff --git a/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/ui/preview/PreviewAccountStateRepository.kt b/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/ui/preview/PreviewAccountStateRepository.kt index 627f48e2e2b..e04aada6a44 100644 --- a/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/ui/preview/PreviewAccountStateRepository.kt +++ b/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/ui/preview/PreviewAccountStateRepository.kt @@ -9,6 +9,7 @@ import com.fsck.k9.mail.AuthType import com.fsck.k9.mail.ServerSettings class PreviewAccountStateRepository : AccountDomainContract.AccountStateRepository { + override fun getState(): AccountState = AccountState( emailAddress = "test@example.com", incomingServerSettings = ServerSettings( @@ -33,17 +34,17 @@ class PreviewAccountStateRepository : AccountDomainContract.AccountStateReposito ), ) - override fun save(accountState: AccountState) = Unit + override fun setState(accountState: AccountState) = Unit - override fun saveEmailAddress(emailAddress: String) = Unit + override fun setEmailAddress(emailAddress: String) = Unit - override fun saveIncomingServerSettings(serverSettings: ServerSettings) = Unit + override fun setIncomingServerSettings(serverSettings: ServerSettings) = Unit - override fun saveOutgoingServerSettings(serverSettings: ServerSettings) = Unit + override fun setOutgoingServerSettings(serverSettings: ServerSettings) = Unit - override fun saveAuthorizationState(authorizationState: AuthorizationState) = Unit + override fun setAuthorizationState(authorizationState: AuthorizationState) = Unit - override fun saveOptions(options: AccountOptions) = Unit + override fun setOptions(options: AccountOptions) = Unit override fun clear() = Unit } diff --git a/feature/account/common/src/test/kotlin/app/k9mail/feature/account/common/data/InMemoryAccountStateRepositoryTest.kt b/feature/account/common/src/test/kotlin/app/k9mail/feature/account/common/data/InMemoryAccountStateRepositoryTest.kt index 0e22332bfb5..5d52ec49352 100644 --- a/feature/account/common/src/test/kotlin/app/k9mail/feature/account/common/data/InMemoryAccountStateRepositoryTest.kt +++ b/feature/account/common/src/test/kotlin/app/k9mail/feature/account/common/data/InMemoryAccountStateRepositoryTest.kt @@ -31,7 +31,7 @@ class InMemoryAccountStateRepositoryTest { } @Test - fun `should save state`() { + fun `should set state`() { val testSubject = InMemoryAccountStateRepository( AccountState( uuid = "uuid", @@ -58,56 +58,56 @@ class InMemoryAccountStateRepositoryTest { ), ) - testSubject.save(newState) + testSubject.setState(newState) assertThat(testSubject.getState()).isEqualTo(newState) } @Test - fun `should save email address`() { + fun `should set email address`() { val testSubject = InMemoryAccountStateRepository() - testSubject.saveEmailAddress("emailAddress") + testSubject.setEmailAddress("emailAddress") assertThat(testSubject.getState().emailAddress) .isEqualTo("emailAddress") } @Test - fun `should save incoming server settings`() { + fun `should set incoming server settings`() { val testSubject = InMemoryAccountStateRepository() - testSubject.saveIncomingServerSettings(INCOMING_SERVER_SETTINGS) + testSubject.setIncomingServerSettings(INCOMING_SERVER_SETTINGS) assertThat(testSubject.getState().incomingServerSettings) .isEqualTo(INCOMING_SERVER_SETTINGS) } @Test - fun `should save outgoing server settings`() { + fun `should set outgoing server settings`() { val testSubject = InMemoryAccountStateRepository() - testSubject.saveOutgoingServerSettings(OUTGOING_SERVER_SETTINGS) + testSubject.setOutgoingServerSettings(OUTGOING_SERVER_SETTINGS) assertThat(testSubject.getState().outgoingServerSettings) .isEqualTo(OUTGOING_SERVER_SETTINGS) } @Test - fun `should save authorization state`() { + fun `should set authorization state`() { val testSubject = InMemoryAccountStateRepository() - testSubject.saveAuthorizationState(AuthorizationState("authorizationState")) + testSubject.setAuthorizationState(AuthorizationState("authorizationState")) assertThat(testSubject.getState().authorizationState) .isEqualTo(AuthorizationState("authorizationState")) } @Test - fun `should save options`() { + fun `should set options`() { val testSubject = InMemoryAccountStateRepository() - testSubject.saveOptions(OPTIONS) + testSubject.setOptions(OPTIONS) assertThat(testSubject.getState().options) .isEqualTo(OPTIONS) diff --git a/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsViewModel.kt b/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsViewModel.kt index 2fcd516201a..4770a61f8a5 100644 --- a/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsViewModel.kt +++ b/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsViewModel.kt @@ -115,7 +115,7 @@ class IncomingServerSettingsViewModel( } if (!hasError) { - accountStateRepository.saveIncomingServerSettings(state.value.toServerSettings()) + accountStateRepository.setIncomingServerSettings(state.value.toServerSettings()) navigateNext() } } diff --git a/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/outgoing/OutgoingServerSettingsViewModel.kt b/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/outgoing/OutgoingServerSettingsViewModel.kt index 75a02f78bb0..3c7c5b08818 100644 --- a/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/outgoing/OutgoingServerSettingsViewModel.kt +++ b/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/outgoing/OutgoingServerSettingsViewModel.kt @@ -78,7 +78,7 @@ class OutgoingServerSettingsViewModel( } if (!hasError) { - accountStateRepository.saveOutgoingServerSettings(state.value.toServerSettings()) + accountStateRepository.setOutgoingServerSettings(state.value.toServerSettings()) navigateNext() } } diff --git a/feature/account/server/settings/src/test/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsViewModelTest.kt b/feature/account/server/settings/src/test/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsViewModelTest.kt index fc4bf185e74..dd225e0d810 100644 --- a/feature/account/server/settings/src/test/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsViewModelTest.kt +++ b/feature/account/server/settings/src/test/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsViewModelTest.kt @@ -56,7 +56,7 @@ class IncomingServerSettingsViewModelTest { ) val turbines = turbinesWithInitialStateCheck(testSubject, State()) - repository.save(accountState) + repository.setState(accountState) testSubject.event(Event.LoadAccountState) diff --git a/feature/account/server/settings/src/test/kotlin/app/k9mail/feature/account/server/settings/ui/outgoing/OutgoingServerSettingsViewModelTest.kt b/feature/account/server/settings/src/test/kotlin/app/k9mail/feature/account/server/settings/ui/outgoing/OutgoingServerSettingsViewModelTest.kt index 2907c3cf054..a055a0651c7 100644 --- a/feature/account/server/settings/src/test/kotlin/app/k9mail/feature/account/server/settings/ui/outgoing/OutgoingServerSettingsViewModelTest.kt +++ b/feature/account/server/settings/src/test/kotlin/app/k9mail/feature/account/server/settings/ui/outgoing/OutgoingServerSettingsViewModelTest.kt @@ -54,7 +54,7 @@ class OutgoingServerSettingsViewModelTest { ) val turbines = turbinesWithInitialStateCheck(testSubject, State()) - repository.save(accountState) + repository.setState(accountState) testSubject.event(Event.LoadAccountState) diff --git a/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/BaseServerValidationViewModel.kt b/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/BaseServerValidationViewModel.kt index acb629f66fa..57fe861160a 100644 --- a/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/BaseServerValidationViewModel.kt +++ b/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/BaseServerValidationViewModel.kt @@ -102,7 +102,7 @@ abstract class BaseServerValidationViewModel( private fun onOAuthResult(result: OAuthResult) { if (result is OAuthResult.Success) { - accountStateRepository.saveAuthorizationState(result.authorizationState) + accountStateRepository.setAuthorizationState(result.authorizationState) updateState { it.copy( needsAuthorization = false, diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupViewModel.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupViewModel.kt index 2e3a90f1203..5c38c8a25c8 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupViewModel.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupViewModel.kt @@ -104,7 +104,7 @@ class AccountSetupViewModel( private fun changeToSetupStep(setupStep: SetupStep) { if (setupStep == SetupStep.AUTO_CONFIG) { - accountStateRepository.saveAuthorizationState(AuthorizationState(null)) + accountStateRepository.setAuthorizationState(AuthorizationState(null)) } updateState { diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryViewModel.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryViewModel.kt index 8aad922fb3a..29b774fda3c 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryViewModel.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryViewModel.kt @@ -250,7 +250,7 @@ internal class AccountAutoDiscoveryViewModel( private fun navigateBack() = emitEffect(Effect.NavigateBack) private fun navigateNext(isAutomaticConfig: Boolean) { - accountStateRepository.save(state.value.toAccountState()) + accountStateRepository.setState(state.value.toAccountState()) emitEffect(Effect.NavigateNext(isAutomaticConfig)) } diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/options/AccountOptionsViewModel.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/options/AccountOptionsViewModel.kt index 9f2b4196cbb..e255e17db36 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/options/AccountOptionsViewModel.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/options/AccountOptionsViewModel.kt @@ -89,7 +89,7 @@ internal class AccountOptionsViewModel( } if (!hasError) { - accountStateRepository.saveOptions(state.value.toAccountOptions()) + accountStateRepository.setOptions(state.value.toAccountOptions()) navigateNext() } } diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupViewModelTest.kt b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupViewModelTest.kt index 3d07a7f9e99..db4d38547c8 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupViewModelTest.kt +++ b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupViewModelTest.kt @@ -132,7 +132,7 @@ class AccountSetupViewModelTest { prop(State::setupStep).isEqualTo(SetupStep.OPTIONS) } - accountStateRepository.save(expectedAccountState) + accountStateRepository.setState(expectedAccountState) viewModel.event(AccountSetupContract.Event.OnNext)