From fd4a7c5716f188d049fa5dbd9c9df19896b44e31 Mon Sep 17 00:00:00 2001 From: Dave Severns <149429124+dseverns-livefront@users.noreply.github.com> Date: Mon, 11 Nov 2024 16:02:35 -0500 Subject: [PATCH] PM-14597 remove notification if device login is decleined (#4256) --- .../LoginWithDeviceViewModel.kt | 27 ++----------------- .../LoginWithDeviceViewModelTest.kt | 24 +++++++---------- 2 files changed, 11 insertions(+), 40 deletions(-) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/loginwithdevice/LoginWithDeviceViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/loginwithdevice/LoginWithDeviceViewModel.kt index 61fb67058..80e7d28d7 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/loginwithdevice/LoginWithDeviceViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/loginwithdevice/LoginWithDeviceViewModel.kt @@ -157,31 +157,8 @@ class LoginWithDeviceViewModel @Inject constructor( } } - CreateAuthRequestResult.Declined -> { - when (state.loginWithDeviceType) { - LoginWithDeviceType.OTHER_DEVICE, - LoginWithDeviceType.SSO_OTHER_DEVICE, - -> { - mutableStateFlow.update { - it.copy( - viewState = LoginWithDeviceState.ViewState.Content( - loginWithDeviceType = it.loginWithDeviceType, - fingerprintPhrase = "", - isResendNotificationLoading = false, - ), - dialogState = LoginWithDeviceState.DialogState.Error( - title = null, - message = R.string.this_request_is_no_longer_valid.asText(), - ), - ) - } - } - - LoginWithDeviceType.SSO_ADMIN_APPROVAL -> { - // Do nothing, the user should not be informed of this state - } - } - } + // Do nothing, the user should not be informed of this state + CreateAuthRequestResult.Declined -> Unit CreateAuthRequestResult.Expired -> { mutableStateFlow.update { diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/loginwithdevice/LoginWithDeviceViewModelTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/loginwithdevice/LoginWithDeviceViewModelTest.kt index ebb9a6b5b..8b67e2f60 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/loginwithdevice/LoginWithDeviceViewModelTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/loginwithdevice/LoginWithDeviceViewModelTest.kt @@ -524,23 +524,17 @@ class LoginWithDeviceViewModelTest : BaseViewModelTest() { @Suppress("MaxLineLength") @Test - fun `on createAuthRequestWithUpdates with OTHER_DEVICE, Declined received should show error dialog`() { - val viewModel = createViewModel() - assertEquals(DEFAULT_STATE, viewModel.stateFlow.value) - mutableCreateAuthRequestWithUpdatesFlow.tryEmit(CreateAuthRequestResult.Declined) - assertEquals( - DEFAULT_STATE.copy( - viewState = DEFAULT_CONTENT_VIEW_STATE.copy( - fingerprintPhrase = "", - isResendNotificationLoading = false, - ), - dialogState = LoginWithDeviceState.DialogState.Error( - title = null, - message = R.string.this_request_is_no_longer_valid.asText(), - ), + fun `on createAuthRequestWithUpdates with OTHER_DEVICE, Declined received should show unchanged content`() { + val initialState = DEFAULT_STATE.copy( + loginWithDeviceType = LoginWithDeviceType.OTHER_DEVICE, + viewState = DEFAULT_CONTENT_VIEW_STATE.copy( + loginWithDeviceType = LoginWithDeviceType.OTHER_DEVICE, ), - viewModel.stateFlow.value, ) + val viewModel = createViewModel(state = initialState) + assertEquals(initialState, viewModel.stateFlow.value) + mutableCreateAuthRequestWithUpdatesFlow.tryEmit(CreateAuthRequestResult.Declined) + assertEquals(initialState, viewModel.stateFlow.value) } @Suppress("MaxLineLength")