taking the personalization feature flag into account when calculating if personalization is supported

- also removes a legacy loading workaround for the account creation step, we're navigating to a new screen AccountCreated so we have to stop the loading
This commit is contained in:
Adam Brown 2022-03-04 17:53:56 +00:00
parent 7e79d7ed0e
commit bdedffbb4f
3 changed files with 16 additions and 20 deletions

View file

@ -767,12 +767,7 @@ class OnboardingViewModel @AssistedInject constructor(
when (isAccountCreated) {
true -> {
val homeServerCapabilities = session.getHomeServerCapabilities()
val capabilityOverrides = vectorOverrides.forceHomeserverCapabilities?.firstOrNull()
val personalizationState = state.personalizationState.copy(
supportsChangingDisplayName = capabilityOverrides?.canChangeDisplayName ?: homeServerCapabilities.canChangeDisplayName,
supportsChangingProfilePicture = capabilityOverrides?.canChangeAvatar ?: homeServerCapabilities.canChangeAvatar
)
val personalizationState = createPersonalizationState(session, state)
setState {
copy(asyncLoginAction = Success(Unit), personalizationState = personalizationState)
}
@ -785,6 +780,20 @@ class OnboardingViewModel @AssistedInject constructor(
}
}
private suspend fun createPersonalizationState(session: Session, state: OnboardingViewState): PersonalizationState {
return when {
vectorFeatures.isOnboardingPersonalizeEnabled() -> {
val homeServerCapabilities = session.getHomeServerCapabilities()
val capabilityOverrides = vectorOverrides.forceHomeserverCapabilities?.firstOrNull()
state.personalizationState.copy(
supportsChangingDisplayName = capabilityOverrides?.canChangeDisplayName ?: homeServerCapabilities.canChangeDisplayName,
supportsChangingProfilePicture = capabilityOverrides?.canChangeAvatar ?: homeServerCapabilities.canChangeAvatar
)
}
else -> state.personalizationState
}
}
private fun handleWebLoginSuccess(action: OnboardingAction.WebLoginSuccess) = withState { state ->
val homeServerConnectionConfigFinal = homeServerConnectionConfigFactory.create(state.homeServerUrl)

View file

@ -22,7 +22,6 @@ import com.airbnb.mvrx.Async
import com.airbnb.mvrx.Loading
import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.PersistState
import com.airbnb.mvrx.Success
import com.airbnb.mvrx.Uninitialized
import im.vector.app.features.login.LoginMode
import im.vector.app.features.login.ServerType
@ -83,10 +82,6 @@ data class OnboardingViewState(
asyncDisplayName is Loading ||
asyncProfilePicture is Loading
}
fun isAuthTaskCompleted(): Boolean {
return asyncLoginAction is Success
}
}
enum class OnboardingFlow {

View file

@ -122,17 +122,9 @@ class FtueAuthVariant(
private fun updateWithState(viewState: OnboardingViewState) {
isForceLoginFallbackEnabled = viewState.isForceLoginFallbackEnabled
views.loginLoading.isVisible = shouldShowLoading(viewState)
views.loginLoading.isVisible = viewState.isLoading()
}
private fun shouldShowLoading(viewState: OnboardingViewState) =
if (vectorFeatures.isOnboardingPersonalizeEnabled()) {
viewState.isLoading()
} else {
// Keep loading when during success because of the delay when switching to the next Activity
viewState.isLoading() || viewState.isAuthTaskCompleted()
}
override fun setIsLoading(isLoading: Boolean) = Unit
private fun handleOnboardingViewEvents(viewEvents: OnboardingViewEvents) {