mirror of
https://github.com/bitwarden/android.git
synced 2024-11-24 02:15:53 +03:00
Clean up special circumstances (#4031)
This commit is contained in:
parent
29f00421bb
commit
78d14547e4
2 changed files with 9 additions and 31 deletions
|
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue