diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingScreen.kt index e6e3fcfe8..1608c36f8 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingScreen.kt @@ -103,7 +103,7 @@ fun LandingScreen( { viewModel.trySendAction( LandingAction.ConfirmSwitchToMatchingAccountClick( - account = dialog.accountSummary, + accountSummary = dialog.accountSummary, ), ) } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingViewModel.kt index 50f1acaf2..b048c7856 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingViewModel.kt @@ -93,13 +93,13 @@ class LandingViewModel @Inject constructor( } private fun handleSwitchAccountClicked(action: LandingAction.SwitchAccountClick) { - authRepository.switchAccount(userId = action.account.userId) + authRepository.switchAccount(userId = action.accountSummary.userId) } private fun handleConfirmSwitchToMatchingAccountClicked( action: LandingAction.ConfirmSwitchToMatchingAccountClick, ) { - authRepository.switchAccount(userId = action.account.userId) + authRepository.switchAccount(userId = action.accountSummary.userId) } private fun handleEmailInputUpdated(action: LandingAction.EmailInputChanged) { @@ -248,17 +248,18 @@ sealed class LandingEvent { */ sealed class LandingAction { /** - * Indicates the user has clicked on the given [account] information in order to switch to it. + * Indicates the user has clicked on the given [accountSummary] information in order to switch + * to it. */ data class SwitchAccountClick( - val account: AccountSummary, + val accountSummary: AccountSummary, ) : LandingAction() /** - * Indicates the user has confirmed they would like to switch to the existing [account]. + * Indicates the user has confirmed they would like to switch to the existing [accountSummary]. */ data class ConfirmSwitchToMatchingAccountClick( - val account: AccountSummary, + val accountSummary: AccountSummary, ) : LandingAction() /** diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModel.kt index 79f91f892..946d0e811 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModel.kt @@ -87,7 +87,7 @@ class LoginViewModel @Inject constructor( } private fun handleSwitchAccountClicked(action: LoginAction.SwitchAccountClick) { - authRepository.switchAccount(userId = action.account.userId) + authRepository.switchAccount(userId = action.accountSummary.userId) } private fun handleReceiveLoginResult(action: LoginAction.Internal.ReceiveLoginResult) { @@ -235,10 +235,11 @@ sealed class LoginEvent { */ sealed class LoginAction { /** - * Indicates the user has clicked on the given [account] information in order to switch to it. + * Indicates the user has clicked on the given [accountSummary] information in order to switch + * to it. */ data class SwitchAccountClick( - val account: AccountSummary, + val accountSummary: AccountSummary, ) : LoginAction() /** diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreen.kt index 3ccb7d97c..3d5c2c5f3 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreen.kt @@ -88,7 +88,7 @@ fun VaultScreen( { viewModel.trySendAction(VaultAction.SearchIconClick) } }, accountSwitchClickAction = remember(viewModel) { - { viewModel.trySendAction(VaultAction.AccountSwitchClick(it)) } + { viewModel.trySendAction(VaultAction.SwitchAccountClick(it)) } }, addAccountClickAction = remember(viewModel) { { viewModel.trySendAction(VaultAction.AddAccountClick) } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultViewModel.kt index 2c50a6ea3..6d452c3f6 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultViewModel.kt @@ -87,7 +87,7 @@ class VaultViewModel @Inject constructor( is VaultAction.IdentityGroupClick -> handleIdentityClick() is VaultAction.LoginGroupClick -> handleLoginClick() is VaultAction.SearchIconClick -> handleSearchIconClick() - is VaultAction.AccountSwitchClick -> handleAccountSwitchClick(action) + is VaultAction.SwitchAccountClick -> handleSwitchAccountClick(action) is VaultAction.AddAccountClick -> handleAddAccountClick() is VaultAction.SecureNoteGroupClick -> handleSecureNoteClick() is VaultAction.TrashClick -> handleTrashClick() @@ -128,7 +128,7 @@ class VaultViewModel @Inject constructor( sendEvent(VaultEvent.NavigateToVaultSearchScreen) } - private fun handleAccountSwitchClick(action: VaultAction.AccountSwitchClick) { + private fun handleSwitchAccountClick(action: VaultAction.SwitchAccountClick) { val isSwitchingAccounts = when (authRepository.switchAccount(userId = action.accountSummary.userId)) { SwitchAccountResult.AccountSwitched -> true @@ -464,7 +464,7 @@ sealed class VaultAction { /** * User clicked an account in the account switcher. */ - data class AccountSwitchClick( + data class SwitchAccountClick( val accountSummary: AccountSummary, ) : VaultAction() diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingScreenTest.kt index 4644d1bc0..dea2591b1 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingScreenTest.kt @@ -341,7 +341,7 @@ class LandingScreenTest : BaseComposeTest() { verify { viewModel.trySendAction( - LandingAction.ConfirmSwitchToMatchingAccountClick(account = accountSummary), + LandingAction.ConfirmSwitchToMatchingAccountClick(accountSummary = accountSummary), ) } } diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreenTest.kt index 4cc9d0dc4..a3d300862 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreenTest.kt @@ -81,14 +81,14 @@ class VaultScreenTest : BaseComposeTest() { @Suppress("MaxLineLength") @Test - fun `account click in the account switcher should send AccountSwitchClick and close switcher`() { + fun `account click in the account switcher should send SwitchAccountClick and close switcher`() { // Open the Account Switcher val accountSummaries = DEFAULT_STATE.accountSummaries composeTestRule.performAccountIconClick() composeTestRule.performAccountClick(accountSummary = LOCKED_ACCOUNT_SUMMARY) - verify { viewModel.trySendAction(VaultAction.AccountSwitchClick(LOCKED_ACCOUNT_SUMMARY)) } + verify { viewModel.trySendAction(VaultAction.SwitchAccountClick(LOCKED_ACCOUNT_SUMMARY)) } composeTestRule.assertSwitcherIsNotDisplayed( accountSummaries = accountSummaries, ) diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultViewModelTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultViewModelTest.kt index 0b85d396a..462df70a7 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultViewModelTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultViewModelTest.kt @@ -81,7 +81,7 @@ class VaultViewModelTest : BaseViewModelTest() { switchAccountResult = SwitchAccountResult.AccountSwitched val updatedUserId = "lockedUserId" viewModel.trySendAction( - VaultAction.AccountSwitchClick( + VaultAction.SwitchAccountClick( accountSummary = mockk() { every { userId } returns updatedUserId }, @@ -146,13 +146,13 @@ class VaultViewModelTest : BaseViewModelTest() { @Suppress("MaxLineLength") @Test - fun `on AccountSwitchClick when result is NoChange should try to switch to the given account and set isSwitchingAccounts to false`() = + fun `on SwitchAccountClick when result is NoChange should try to switch to the given account and set isSwitchingAccounts to false`() = runTest { val viewModel = createViewModel() switchAccountResult = SwitchAccountResult.NoChange val updatedUserId = "lockedUserId" viewModel.trySendAction( - VaultAction.AccountSwitchClick( + VaultAction.SwitchAccountClick( accountSummary = mockk { every { userId } returns updatedUserId }, @@ -167,13 +167,13 @@ class VaultViewModelTest : BaseViewModelTest() { @Suppress("MaxLineLength") @Test - fun `on AccountSwitchClick when result is AccountSwitched should switch to the given account and set isSwitchingAccounts to true`() = + fun `on SwitchAccountClick when result is AccountSwitched should switch to the given account and set isSwitchingAccounts to true`() = runTest { val viewModel = createViewModel() switchAccountResult = SwitchAccountResult.AccountSwitched val updatedUserId = "lockedUserId" viewModel.trySendAction( - VaultAction.AccountSwitchClick( + VaultAction.SwitchAccountClick( accountSummary = mockk { every { userId } returns updatedUserId }, @@ -312,7 +312,7 @@ class VaultViewModelTest : BaseViewModelTest() { switchAccountResult = SwitchAccountResult.AccountSwitched val updatedUserId = "lockedUserId" viewModel.trySendAction( - VaultAction.AccountSwitchClick( + VaultAction.SwitchAccountClick( accountSummary = mockk() { every { userId } returns updatedUserId },