Fix minor optimization issues (#979)

This commit is contained in:
David Perez 2024-02-07 15:13:27 -06:00 committed by Álison Fernandes
parent 80a024f9dd
commit 0ebddadcae
5 changed files with 8 additions and 10 deletions

View file

@ -736,11 +736,11 @@ class AuthRepositoryImpl(
.userState
?.activeAccount
?: return ResetPasswordResult.Error
val currentPasswordHash = currentPassword?.let {
val currentPasswordHash = currentPassword?.let { password ->
authSdkSource
.hashPassword(
email = activeAccount.profile.email,
password = it,
password = password,
kdf = activeAccount.profile.toSdkParams(),
purpose = HashPurpose.SERVER_AUTHORIZATION,
)

View file

@ -309,8 +309,7 @@ class EnterpriseSignOnViewModel @Inject constructor(
showLoading()
viewModelScope.launch {
val prevalidateSsoResult = authRepository.prevalidateSso(organizationIdentifier)
when (prevalidateSsoResult) {
when (val prevalidateSso = authRepository.prevalidateSso(organizationIdentifier)) {
is PrevalidateSsoResult.Failure -> {
sendAction(EnterpriseSignOnAction.Internal.OnSsoPrevalidationFailure)
}
@ -318,7 +317,7 @@ class EnterpriseSignOnViewModel @Inject constructor(
is PrevalidateSsoResult.Success -> {
prepareAndLaunchCustomTab(
organizationIdentifier = organizationIdentifier,
prevalidateSsoResult = prevalidateSsoResult,
prevalidateSsoResult = prevalidateSso,
)
}
}

View file

@ -26,7 +26,7 @@ abstract class BaseViewModel<S, E, A>(
initialState: S,
) : ViewModel() {
protected val mutableStateFlow: MutableStateFlow<S> = MutableStateFlow(initialState)
protected val eventChannel: Channel<E> = Channel(capacity = Channel.UNLIMITED)
private val eventChannel: Channel<E> = Channel(capacity = Channel.UNLIMITED)
private val internalActionChannel: Channel<A> = Channel(capacity = Channel.UNLIMITED)
/**

View file

@ -59,9 +59,9 @@ class LoginApprovalViewModel @Inject constructor(
init {
state
.specialCircumstance
?.let {
?.let { circumstance ->
authRepository
.getAuthRequestByIdFlow(it.passwordlessRequestData.loginRequestId)
.getAuthRequestByIdFlow(circumstance.passwordlessRequestData.loginRequestId)
.map { LoginApprovalAction.Internal.AuthRequestResultReceive(it) }
.onEach(::sendAction)
.launchIn(viewModelScope)

View file

@ -105,10 +105,9 @@ class BlockAutoFillViewModel @Inject constructor(
.filter { uri ->
uri in settingsRepository.blockedAutofillUris || !uri.isValidPattern()
}
.mapNotNull { uri ->
.firstNotNullOfOrNull { uri ->
uri.validateUri(settingsRepository.blockedAutofillUris)
}
.firstOrNull()
if (errorText != null) {
mutableStateFlow.update { currentState ->