Standardize naming of actions related to account switcher (#363)

This commit is contained in:
Brian Yencho
2023-12-11 11:49:32 -06:00
committed by Álison Fernandes
parent 8855fda026
commit 82d7c307ff
8 changed files with 25 additions and 23 deletions

View File

@@ -103,7 +103,7 @@ fun LandingScreen(
{
viewModel.trySendAction(
LandingAction.ConfirmSwitchToMatchingAccountClick(
account = dialog.accountSummary,
accountSummary = dialog.accountSummary,
),
)
}

View File

@@ -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()
/**

View File

@@ -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()
/**

View File

@@ -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) }

View File

@@ -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()