Clean up special circumstances (#4031)

This commit is contained in:
David Perez 2024-10-04 11:23:17 -05:00 committed by GitHub
parent 29f00421bb
commit 78d14547e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 31 deletions

View file

@ -13,16 +13,7 @@ import com.x8bit.bitwarden.data.platform.manager.model.SpecialCircumstance
fun SpecialCircumstance.toAutofillSaveItemOrNull(): AutofillSaveItem? = fun SpecialCircumstance.toAutofillSaveItemOrNull(): AutofillSaveItem? =
when (this) { when (this) {
is SpecialCircumstance.AutofillSave -> this.autofillSaveItem is SpecialCircumstance.AutofillSave -> this.autofillSaveItem
is SpecialCircumstance.AutofillSelection -> null else -> 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
} }
/** /**
@ -30,17 +21,8 @@ fun SpecialCircumstance.toAutofillSaveItemOrNull(): AutofillSaveItem? =
*/ */
fun SpecialCircumstance.toAutofillSelectionDataOrNull(): AutofillSelectionData? = fun SpecialCircumstance.toAutofillSelectionDataOrNull(): AutofillSelectionData? =
when (this) { when (this) {
is SpecialCircumstance.AutofillSave -> null
is SpecialCircumstance.AutofillSelection -> this.autofillSelectionData is SpecialCircumstance.AutofillSelection -> this.autofillSelectionData
is SpecialCircumstance.PasswordlessRequest -> null else -> 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
} }
/** /**

View file

@ -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.clipboard.BitwardenClipboardManager
import com.x8bit.bitwarden.data.platform.manager.event.OrganizationEventManager 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.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.toAutofillSelectionDataOrNull
import com.x8bit.bitwarden.data.platform.manager.util.toFido2AssertionRequestOrNull 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.manager.util.toFido2RequestOrNull
import com.x8bit.bitwarden.data.platform.repository.EnvironmentRepository import com.x8bit.bitwarden.data.platform.repository.EnvironmentRepository
import com.x8bit.bitwarden.data.platform.repository.SettingsRepository import com.x8bit.bitwarden.data.platform.repository.SettingsRepository
@ -107,12 +107,7 @@ class VaultItemListingViewModel @Inject constructor(
val activeAccountSummary = userState.toActiveAccountSummary() val activeAccountSummary = userState.toActiveAccountSummary()
val accountSummaries = userState.toAccountSummaries() val accountSummaries = userState.toAccountSummaries()
val specialCircumstance = specialCircumstanceManager.specialCircumstance val specialCircumstance = specialCircumstanceManager.specialCircumstance
val fido2CreationData = specialCircumstance as? SpecialCircumstance.Fido2Save val fido2CredentialRequest = specialCircumstance?.toFido2RequestOrNull()
val fido2AssertionData = specialCircumstance as? SpecialCircumstance.Fido2Assertion
val fido2GetCredentialsData =
specialCircumstance as? SpecialCircumstance.Fido2GetCredentials
val dialogState = fido2CreationData
?.let { VaultItemListingState.DialogState.Loading(R.string.loading.asText()) }
VaultItemListingState( VaultItemListingState(
itemListingType = VaultItemListingArgs(savedStateHandle = savedStateHandle) itemListingType = VaultItemListingArgs(savedStateHandle = savedStateHandle)
.vaultItemListingType .vaultItemListingType
@ -125,15 +120,16 @@ class VaultItemListingViewModel @Inject constructor(
baseIconUrl = environmentRepository.environment.environmentUrlData.baseIconUrl, baseIconUrl = environmentRepository.environment.environmentUrlData.baseIconUrl,
isIconLoadingDisabled = settingsRepository.isIconLoadingDisabled, isIconLoadingDisabled = settingsRepository.isIconLoadingDisabled,
isPullToRefreshSettingEnabled = settingsRepository.getPullToRefreshEnabledFlow().value, isPullToRefreshSettingEnabled = settingsRepository.getPullToRefreshEnabledFlow().value,
dialogState = dialogState, dialogState = fido2CredentialRequest
?.let { VaultItemListingState.DialogState.Loading(R.string.loading.asText()) },
policyDisablesSend = policyManager policyDisablesSend = policyManager
.getActivePolicies(type = PolicyTypeJson.DISABLE_SEND) .getActivePolicies(type = PolicyTypeJson.DISABLE_SEND)
.any(), .any(),
autofillSelectionData = specialCircumstance?.toAutofillSelectionDataOrNull(), autofillSelectionData = specialCircumstance?.toAutofillSelectionDataOrNull(),
hasMasterPassword = userState.activeAccount.hasMasterPassword, hasMasterPassword = userState.activeAccount.hasMasterPassword,
fido2CredentialRequest = fido2CreationData?.fido2CredentialRequest, fido2CredentialRequest = fido2CredentialRequest,
fido2CredentialAssertionRequest = fido2AssertionData?.fido2AssertionRequest, fido2CredentialAssertionRequest = specialCircumstance?.toFido2AssertionRequestOrNull(),
fido2GetCredentialsRequest = fido2GetCredentialsData?.fido2GetCredentialsRequest, fido2GetCredentialsRequest = specialCircumstance?.toFido2GetCredentialsRequestOrNull(),
isPremium = userState.activeAccount.isPremium, isPremium = userState.activeAccount.isPremium,
isRefreshing = false, isRefreshing = false,
) )