Skip to content

Commit

Permalink
taking the personalization feature flag into account when calculating…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
ouchadam committed Mar 4, 2022
1 parent a8e38dc commit c3c193d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -83,10 +82,6 @@ data class OnboardingViewState(
asyncDisplayName is Loading ||
asyncProfilePicture is Loading
}

fun isAuthTaskCompleted(): Boolean {
return asyncLoginAction is Success
}
}

enum class OnboardingFlow {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c3c193d

Please sign in to comment.