mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 19:36:08 +03:00
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:
parent
7e79d7ed0e
commit
bdedffbb4f
3 changed files with 16 additions and 20 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue