diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/verificationcode/VerificationCodeViewModel.kt b/app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/verificationcode/VerificationCodeViewModel.kt index 30ec9e1057..f37cb5b991 100644 --- a/app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/verificationcode/VerificationCodeViewModel.kt +++ b/app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/verificationcode/VerificationCodeViewModel.kt @@ -57,6 +57,11 @@ class VerificationCodeViewModel @Inject constructor( viewState = VerificationCodeState.ViewState.Loading, dialogState = null, isRefreshing = false, + hasMasterPassword = authRepository + .userStateFlow + .value + ?.activeAccount + ?.hasMasterPassword == true, ) }, ) { @@ -83,11 +88,8 @@ class VerificationCodeViewModel @Inject constructor( listDataState } } - .onEach { - sendAction( - VerificationCodeAction.Internal.AuthCodesReceive(it), - ) - } + .map { VerificationCodeAction.Internal.AuthCodesReceive(it) } + .onEach(::sendAction) .launchIn(viewModelScope) } @@ -363,7 +365,7 @@ class VerificationCodeViewModel @Inject constructor( VerificationCodeDisplayItem( id = item.id, authCode = item.code, - hideAuthCode = item.hasPasswordReprompt, + hideAuthCode = item.hasPasswordReprompt && state.hasMasterPassword, label = item.name, supportingLabel = item.username, periodSeconds = item.periodSeconds, @@ -412,6 +414,7 @@ data class VerificationCodeState( val dialogState: DialogState?, val isPullToRefreshSettingEnabled: Boolean, val isRefreshing: Boolean, + val hasMasterPassword: Boolean, ) : Parcelable { /** diff --git a/app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/verificationcode/VerificationCodeScreenTest.kt b/app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/verificationcode/VerificationCodeScreenTest.kt index f6e532163c..18b93c41b9 100644 --- a/app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/verificationcode/VerificationCodeScreenTest.kt +++ b/app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/verificationcode/VerificationCodeScreenTest.kt @@ -518,4 +518,5 @@ private val DEFAULT_STATE = VerificationCodeState( isPullToRefreshSettingEnabled = false, dialogState = null, isRefreshing = false, + hasMasterPassword = false, ) diff --git a/app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/verificationcode/VerificationCodeViewModelTest.kt b/app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/verificationcode/VerificationCodeViewModelTest.kt index fc8256e2da..5541250377 100644 --- a/app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/verificationcode/VerificationCodeViewModelTest.kt +++ b/app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/verificationcode/VerificationCodeViewModelTest.kt @@ -64,6 +64,7 @@ class VerificationCodeViewModelTest : BaseViewModelTest() { private val mockUserAccount: UserState.Account = mockk { every { isPremium } returns true + every { hasMasterPassword } returns true } private val mockUserState: UserState = mockk { @@ -602,7 +603,6 @@ class VerificationCodeViewModelTest : BaseViewModelTest() { authRepository = authRepository, ) - @Suppress("MaxLineLength") private fun createVerificationCodeState( viewState: VerificationCodeState.ViewState = VerificationCodeState.ViewState.Loading, ) = VerificationCodeState( @@ -613,6 +613,7 @@ class VerificationCodeViewModelTest : BaseViewModelTest() { dialogState = null, isPullToRefreshSettingEnabled = settingsRepository.getPullToRefreshEnabledFlow().value, isRefreshing = false, + hasMasterPassword = true, ) private fun createDisplayItemList() = listOf(