diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorViewModel.kt index f6224018d..b0b6f13ed 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorViewModel.kt @@ -105,33 +105,22 @@ class GeneratorViewModel @Inject constructor( } } - @Suppress("MaxLineLength", "LongMethod") override fun handleAction(action: GeneratorAction) { when (action) { - is GeneratorAction.PasswordHistoryClick -> { - handlePasswordHistoryClick() - } - - is GeneratorAction.CloseClick -> { - handleCloseClick() - } - - is GeneratorAction.SelectClick -> { - handleSelectClick() - } - - is GeneratorAction.RegenerateClick -> { - handleRegenerationClick() - } - - is GeneratorAction.CopyClick -> { - handleCopyClick() - } - - is GeneratorAction.MainTypeOptionSelect -> { - handleMainTypeOptionSelect(action) - } + is GeneratorAction.PasswordHistoryClick -> handlePasswordHistoryClick() + is GeneratorAction.CloseClick -> handleCloseClick() + is GeneratorAction.SelectClick -> handleSelectClick() + is GeneratorAction.RegenerateClick -> handleRegenerationClick() + is GeneratorAction.CopyClick -> handleCopyClick() + is GeneratorAction.MainTypeOptionSelect -> handleMainTypeOptionSelect(action) + is GeneratorAction.MainType -> handleMainTypeAction(action) + is GeneratorAction.Internal -> handleInternalAction(action) + } + } + @Suppress("MaxLineLength") + private fun handleMainTypeAction(action: GeneratorAction.MainType) { + when (action) { is GeneratorAction.MainType.Passcode.PasscodeTypeOptionSelect -> { handlePasscodeTypeOptionSelect(action) } @@ -144,30 +133,6 @@ class GeneratorViewModel @Inject constructor( handlePassphraseSpecificAction(action) } - is GeneratorAction.Internal.UpdateGeneratedPasswordResult -> { - handleUpdateGeneratedPasswordResult(action) - } - - is GeneratorAction.Internal.UpdateGeneratedPassphraseResult -> { - handleUpdateGeneratedPassphraseResult(action) - } - - is GeneratorAction.Internal.UpdateGeneratedPlusAddessedUsernameResult -> { - handleUpdatePlusAddressedGeneratedUsernameResult(action) - } - - is GeneratorAction.Internal.UpdateGeneratedCatchAllUsernameResult -> { - handleUpdateCatchAllGeneratedUsernameResult(action) - } - - is GeneratorAction.Internal.UpdateGeneratedRandomWordUsernameResult -> { - handleUpdateRandomWordGeneratedUsernameResult(action) - } - - is GeneratorAction.Internal.UpdateGeneratedForwardedServiceUsernameResult -> { - handleUpdateForwardedServiceGeneratedUsernameResult(action) - } - is GeneratorAction.MainType.Username.UsernameTypeOptionSelect -> { handleUsernameTypeOptionSelect(action) } @@ -214,6 +179,34 @@ class GeneratorViewModel @Inject constructor( } } + private fun handleInternalAction(action: GeneratorAction.Internal) { + when (action) { + is GeneratorAction.Internal.UpdateGeneratedPasswordResult -> { + handleUpdateGeneratedPasswordResult(action) + } + + is GeneratorAction.Internal.UpdateGeneratedPassphraseResult -> { + handleUpdateGeneratedPassphraseResult(action) + } + + is GeneratorAction.Internal.UpdateGeneratedPlusAddessedUsernameResult -> { + handleUpdatePlusAddressedGeneratedUsernameResult(action) + } + + is GeneratorAction.Internal.UpdateGeneratedCatchAllUsernameResult -> { + handleUpdateCatchAllGeneratedUsernameResult(action) + } + + is GeneratorAction.Internal.UpdateGeneratedRandomWordUsernameResult -> { + handleUpdateRandomWordGeneratedUsernameResult(action) + } + + is GeneratorAction.Internal.UpdateGeneratedForwardedServiceUsernameResult -> { + handleUpdateForwardedServiceGeneratedUsernameResult(action) + } + } + } + //endregion Initialization and Overrides //region Top Level Handlers @@ -2111,7 +2104,7 @@ sealed class GeneratorAction { /** * Represents the action to learn more. */ - data object TooltipClick : GeneratorAction() + data object TooltipClick : UsernameType() /** * Represents actions specifically related to Forwarded Email Alias.