diff --git a/app/src/main/java/com/x8bit/bitwarden/data/platform/manager/util/SpecialCircumstanceExtensions.kt b/app/src/main/java/com/x8bit/bitwarden/data/platform/manager/util/SpecialCircumstanceExtensions.kt index a8a737225..02953510f 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/platform/manager/util/SpecialCircumstanceExtensions.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/platform/manager/util/SpecialCircumstanceExtensions.kt @@ -13,16 +13,7 @@ import com.x8bit.bitwarden.data.platform.manager.model.SpecialCircumstance fun SpecialCircumstance.toAutofillSaveItemOrNull(): AutofillSaveItem? = when (this) { is SpecialCircumstance.AutofillSave -> this.autofillSaveItem - is SpecialCircumstance.AutofillSelection -> null - is SpecialCircumstance.PasswordlessRequest -> null - is SpecialCircumstance.ShareNewSend -> null - SpecialCircumstance.GeneratorShortcut -> null - SpecialCircumstance.VaultShortcut -> null - is SpecialCircumstance.Fido2Save -> null - is SpecialCircumstance.Fido2Assertion -> null - is SpecialCircumstance.Fido2GetCredentials -> null - is SpecialCircumstance.RegistrationEvent.CompleteRegistration -> null - SpecialCircumstance.RegistrationEvent.ExpiredRegistrationLink -> null + else -> null } /** @@ -30,17 +21,8 @@ fun SpecialCircumstance.toAutofillSaveItemOrNull(): AutofillSaveItem? = */ fun SpecialCircumstance.toAutofillSelectionDataOrNull(): AutofillSelectionData? = when (this) { - is SpecialCircumstance.AutofillSave -> null is SpecialCircumstance.AutofillSelection -> this.autofillSelectionData - is SpecialCircumstance.PasswordlessRequest -> null - is SpecialCircumstance.ShareNewSend -> null - SpecialCircumstance.GeneratorShortcut -> null - SpecialCircumstance.VaultShortcut -> null - is SpecialCircumstance.Fido2Save -> null - is SpecialCircumstance.Fido2Assertion -> null - is SpecialCircumstance.Fido2GetCredentials -> null - is SpecialCircumstance.RegistrationEvent.CompleteRegistration -> null - SpecialCircumstance.RegistrationEvent.ExpiredRegistrationLink -> null + else -> null } /** diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingViewModel.kt index 9d0ddeea2..4235716f2 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingViewModel.kt @@ -29,9 +29,9 @@ import com.x8bit.bitwarden.data.platform.manager.ciphermatching.CipherMatchingMa import com.x8bit.bitwarden.data.platform.manager.clipboard.BitwardenClipboardManager import com.x8bit.bitwarden.data.platform.manager.event.OrganizationEventManager import com.x8bit.bitwarden.data.platform.manager.model.OrganizationEvent -import com.x8bit.bitwarden.data.platform.manager.model.SpecialCircumstance import com.x8bit.bitwarden.data.platform.manager.util.toAutofillSelectionDataOrNull import com.x8bit.bitwarden.data.platform.manager.util.toFido2AssertionRequestOrNull +import com.x8bit.bitwarden.data.platform.manager.util.toFido2GetCredentialsRequestOrNull import com.x8bit.bitwarden.data.platform.manager.util.toFido2RequestOrNull import com.x8bit.bitwarden.data.platform.repository.EnvironmentRepository import com.x8bit.bitwarden.data.platform.repository.SettingsRepository @@ -107,12 +107,7 @@ class VaultItemListingViewModel @Inject constructor( val activeAccountSummary = userState.toActiveAccountSummary() val accountSummaries = userState.toAccountSummaries() val specialCircumstance = specialCircumstanceManager.specialCircumstance - val fido2CreationData = specialCircumstance as? SpecialCircumstance.Fido2Save - val fido2AssertionData = specialCircumstance as? SpecialCircumstance.Fido2Assertion - val fido2GetCredentialsData = - specialCircumstance as? SpecialCircumstance.Fido2GetCredentials - val dialogState = fido2CreationData - ?.let { VaultItemListingState.DialogState.Loading(R.string.loading.asText()) } + val fido2CredentialRequest = specialCircumstance?.toFido2RequestOrNull() VaultItemListingState( itemListingType = VaultItemListingArgs(savedStateHandle = savedStateHandle) .vaultItemListingType @@ -125,15 +120,16 @@ class VaultItemListingViewModel @Inject constructor( baseIconUrl = environmentRepository.environment.environmentUrlData.baseIconUrl, isIconLoadingDisabled = settingsRepository.isIconLoadingDisabled, isPullToRefreshSettingEnabled = settingsRepository.getPullToRefreshEnabledFlow().value, - dialogState = dialogState, + dialogState = fido2CredentialRequest + ?.let { VaultItemListingState.DialogState.Loading(R.string.loading.asText()) }, policyDisablesSend = policyManager .getActivePolicies(type = PolicyTypeJson.DISABLE_SEND) .any(), autofillSelectionData = specialCircumstance?.toAutofillSelectionDataOrNull(), hasMasterPassword = userState.activeAccount.hasMasterPassword, - fido2CredentialRequest = fido2CreationData?.fido2CredentialRequest, - fido2CredentialAssertionRequest = fido2AssertionData?.fido2AssertionRequest, - fido2GetCredentialsRequest = fido2GetCredentialsData?.fido2GetCredentialsRequest, + fido2CredentialRequest = fido2CredentialRequest, + fido2CredentialAssertionRequest = specialCircumstance?.toFido2AssertionRequestOrNull(), + fido2GetCredentialsRequest = specialCircumstance?.toFido2GetCredentialsRequestOrNull(), isPremium = userState.activeAccount.isPremium, isRefreshing = false, )