mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 09:25:49 +03:00
Add the new value to the ViewEvent, because the state is maybe not up to date.
This commit is contained in:
parent
cfdf5cb552
commit
8b1a07b8a8
4 changed files with 15 additions and 23 deletions
|
@ -151,8 +151,8 @@ open class LoginActivity : VectorBaseActivity(), ToolbarConfigurable {
|
||||||
// TODO Disabled because it provokes a flickering
|
// TODO Disabled because it provokes a flickering
|
||||||
// ft.setCustomAnimations(enterAnim, exitAnim, popEnterAnim, popExitAnim)
|
// ft.setCustomAnimations(enterAnim, exitAnim, popEnterAnim, popExitAnim)
|
||||||
})
|
})
|
||||||
is LoginViewEvents.OnServerSelectionDone -> onServerSelectionDone()
|
is LoginViewEvents.OnServerSelectionDone -> onServerSelectionDone(loginViewEvents)
|
||||||
is LoginViewEvents.OnSignModeSelected -> onSignModeSelected()
|
is LoginViewEvents.OnSignModeSelected -> onSignModeSelected(loginViewEvents)
|
||||||
is LoginViewEvents.OnLoginFlowRetrieved ->
|
is LoginViewEvents.OnLoginFlowRetrieved ->
|
||||||
addFragmentToBackstack(R.id.loginFragmentContainer,
|
addFragmentToBackstack(R.id.loginFragmentContainer,
|
||||||
if (loginViewEvents.isSso) {
|
if (loginViewEvents.isSso) {
|
||||||
|
@ -228,8 +228,8 @@ open class LoginActivity : VectorBaseActivity(), ToolbarConfigurable {
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onServerSelectionDone() = withState(loginViewModel) { state ->
|
private fun onServerSelectionDone(loginViewEvents: LoginViewEvents.OnServerSelectionDone) {
|
||||||
when (state.serverType) {
|
when (loginViewEvents.serverType) {
|
||||||
ServerType.MatrixOrg -> Unit // In this case, we wait for the login flow
|
ServerType.MatrixOrg -> Unit // In this case, we wait for the login flow
|
||||||
ServerType.Modular,
|
ServerType.Modular,
|
||||||
ServerType.Other -> addFragmentToBackstack(R.id.loginFragmentContainer,
|
ServerType.Other -> addFragmentToBackstack(R.id.loginFragmentContainer,
|
||||||
|
@ -239,8 +239,9 @@ open class LoginActivity : VectorBaseActivity(), ToolbarConfigurable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onSignModeSelected() = withState(loginViewModel) { state ->
|
private fun onSignModeSelected(loginViewEvents: LoginViewEvents.OnSignModeSelected) = withState(loginViewModel) { state ->
|
||||||
when (state.signMode) {
|
// state.signMode could not be ready yet. So use value from the ViewEvent
|
||||||
|
when (loginViewEvents.signMode) {
|
||||||
SignMode.Unknown -> error("Sign mode has to be set before calling this method")
|
SignMode.Unknown -> error("Sign mode has to be set before calling this method")
|
||||||
SignMode.SignUp -> {
|
SignMode.SignUp -> {
|
||||||
// This is managed by the LoginViewEvents
|
// This is managed by the LoginViewEvents
|
||||||
|
|
|
@ -33,9 +33,9 @@ sealed class LoginViewEvents : VectorViewEvents {
|
||||||
// Navigation event
|
// Navigation event
|
||||||
|
|
||||||
object OpenServerSelection : LoginViewEvents()
|
object OpenServerSelection : LoginViewEvents()
|
||||||
object OnServerSelectionDone : LoginViewEvents()
|
data class OnServerSelectionDone(val serverType: ServerType) : LoginViewEvents()
|
||||||
data class OnLoginFlowRetrieved(val isSso: Boolean) : LoginViewEvents()
|
data class OnLoginFlowRetrieved(val isSso: Boolean) : LoginViewEvents()
|
||||||
object OnSignModeSelected : LoginViewEvents()
|
data class OnSignModeSelected(val signMode: SignMode) : LoginViewEvents()
|
||||||
object OnForgetPasswordClicked : LoginViewEvents()
|
object OnForgetPasswordClicked : LoginViewEvents()
|
||||||
object OnResetPasswordSendThreePidDone : LoginViewEvents()
|
object OnResetPasswordSendThreePidDone : LoginViewEvents()
|
||||||
object OnResetPasswordMailConfirmationSuccess : LoginViewEvents()
|
object OnResetPasswordMailConfirmationSuccess : LoginViewEvents()
|
||||||
|
|
|
@ -19,7 +19,6 @@ package im.vector.riotx.features.login
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.lifecycle.viewModelScope
|
|
||||||
import com.airbnb.mvrx.ActivityViewModelContext
|
import com.airbnb.mvrx.ActivityViewModelContext
|
||||||
import com.airbnb.mvrx.Fail
|
import com.airbnb.mvrx.Fail
|
||||||
import com.airbnb.mvrx.Loading
|
import com.airbnb.mvrx.Loading
|
||||||
|
@ -54,8 +53,6 @@ import im.vector.riotx.features.call.WebRtcPeerConnectionManager
|
||||||
import im.vector.riotx.features.notifications.PushRuleTriggerListener
|
import im.vector.riotx.features.notifications.PushRuleTriggerListener
|
||||||
import im.vector.riotx.features.session.SessionListener
|
import im.vector.riotx.features.session.SessionListener
|
||||||
import im.vector.riotx.features.signout.soft.SoftLogoutActivity
|
import im.vector.riotx.features.signout.soft.SoftLogoutActivity
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.concurrent.CancellationException
|
import java.util.concurrent.CancellationException
|
||||||
|
|
||||||
|
@ -402,14 +399,7 @@ class LoginViewModel @AssistedInject constructor(
|
||||||
when (action.signMode) {
|
when (action.signMode) {
|
||||||
SignMode.SignUp -> startRegistrationFlow()
|
SignMode.SignUp -> startRegistrationFlow()
|
||||||
SignMode.SignIn -> startAuthenticationFlow()
|
SignMode.SignIn -> startAuthenticationFlow()
|
||||||
SignMode.SignInWithMatrixId -> {
|
SignMode.SignInWithMatrixId -> _viewEvents.post(LoginViewEvents.OnSignModeSelected(SignMode.SignInWithMatrixId))
|
||||||
viewModelScope.launch {
|
|
||||||
// Add a delay to avoid crash
|
|
||||||
delay(50)
|
|
||||||
_viewEvents.post(LoginViewEvents.OnSignModeSelected)
|
|
||||||
}
|
|
||||||
Unit
|
|
||||||
}
|
|
||||||
SignMode.Unknown -> Unit
|
SignMode.Unknown -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -427,7 +417,7 @@ class LoginViewModel @AssistedInject constructor(
|
||||||
// Request login flow here
|
// Request login flow here
|
||||||
handle(LoginAction.UpdateHomeServer(matrixOrgUrl))
|
handle(LoginAction.UpdateHomeServer(matrixOrgUrl))
|
||||||
ServerType.Modular,
|
ServerType.Modular,
|
||||||
ServerType.Other -> _viewEvents.post(LoginViewEvents.OnServerSelectionDone)
|
ServerType.Other -> _viewEvents.post(LoginViewEvents.OnServerSelectionDone(action.serverType))
|
||||||
}.exhaustive
|
}.exhaustive
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,7 +651,7 @@ class LoginViewModel @AssistedInject constructor(
|
||||||
// Ensure Wizard is ready
|
// Ensure Wizard is ready
|
||||||
loginWizard
|
loginWizard
|
||||||
|
|
||||||
_viewEvents.post(LoginViewEvents.OnSignModeSelected)
|
_viewEvents.post(LoginViewEvents.OnSignModeSelected(SignMode.SignIn))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onFlowResponse(flowResult: FlowResult) {
|
private fun onFlowResponse(flowResult: FlowResult) {
|
||||||
|
|
|
@ -93,8 +93,9 @@ class SoftLogoutFragment @Inject constructor(
|
||||||
softLogoutViewModel.handle(SoftLogoutAction.SignInAgain(password))
|
softLogoutViewModel.handle(SoftLogoutAction.SignInAgain(password))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun signinFallbackSubmit() {
|
override fun signinFallbackSubmit() = withState(loginViewModel) { state ->
|
||||||
loginViewModel.handle(LoginAction.PostViewEvent(LoginViewEvents.OnSignModeSelected))
|
// The loginViewModel has been prepared for a SSO/login fallback recovery (above)
|
||||||
|
loginViewModel.handle(LoginAction.PostViewEvent(LoginViewEvents.OnSignModeSelected(state.signMode)))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearData() {
|
override fun clearData() {
|
||||||
|
|
Loading…
Reference in a new issue