mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
formatting
This commit is contained in:
parent
befcfe8c5b
commit
6681d4fe17
4 changed files with 49 additions and 49 deletions
|
@ -147,18 +147,18 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
is OnboardingAction.WebLoginSuccess -> handleWebLoginSuccess(action)
|
||||
is OnboardingAction.ResetPassword -> handleResetPassword(action)
|
||||
is OnboardingAction.ResetPasswordMailConfirmed -> handleResetPasswordMailConfirmed()
|
||||
is OnboardingAction.PostRegisterAction -> handleRegisterAction(action.registerAction)
|
||||
is OnboardingAction.ResetAction -> handleResetAction(action)
|
||||
is OnboardingAction.UserAcceptCertificate -> handleUserAcceptCertificate(action)
|
||||
OnboardingAction.ClearHomeServerHistory -> handleClearHomeServerHistory()
|
||||
is OnboardingAction.UpdateDisplayName -> updateDisplayName(action.displayName)
|
||||
OnboardingAction.UpdateDisplayNameSkipped -> handleDisplayNameStepComplete()
|
||||
OnboardingAction.UpdateProfilePictureSkipped -> completePersonalization()
|
||||
OnboardingAction.PersonalizeProfile -> handlePersonalizeProfile()
|
||||
is OnboardingAction.ProfilePictureSelected -> handleProfilePictureSelected(action)
|
||||
OnboardingAction.SaveSelectedProfilePicture -> updateProfilePicture()
|
||||
is OnboardingAction.PostViewEvent -> _viewEvents.post(action.viewEvent)
|
||||
OnboardingAction.StopEmailValidationCheck -> cancelWaitForEmailValidation()
|
||||
is OnboardingAction.PostRegisterAction -> handleRegisterAction(action.registerAction)
|
||||
is OnboardingAction.ResetAction -> handleResetAction(action)
|
||||
is OnboardingAction.UserAcceptCertificate -> handleUserAcceptCertificate(action)
|
||||
OnboardingAction.ClearHomeServerHistory -> handleClearHomeServerHistory()
|
||||
is OnboardingAction.UpdateDisplayName -> updateDisplayName(action.displayName)
|
||||
OnboardingAction.UpdateDisplayNameSkipped -> handleDisplayNameStepComplete()
|
||||
OnboardingAction.UpdateProfilePictureSkipped -> completePersonalization()
|
||||
OnboardingAction.PersonalizeProfile -> handlePersonalizeProfile()
|
||||
is OnboardingAction.ProfilePictureSelected -> handleProfilePictureSelected(action)
|
||||
OnboardingAction.SaveSelectedProfilePicture -> updateProfilePicture()
|
||||
is OnboardingAction.PostViewEvent -> _viewEvents.post(action.viewEvent)
|
||||
OnboardingAction.StopEmailValidationCheck -> cancelWaitForEmailValidation()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,10 +276,10 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
runCatching { registrationActionHandler.processAction(awaitState().selectedHomeserver, action) }.fold(
|
||||
onSuccess = {
|
||||
when (it) {
|
||||
RegistrationActionHandler.Result.Ignored -> {
|
||||
RegistrationActionHandler.Result.Ignored -> {
|
||||
// do nothing
|
||||
}
|
||||
is RegistrationActionHandler.Result.NextStage -> {
|
||||
is RegistrationActionHandler.Result.NextStage -> {
|
||||
overrideNextStage?.invoke() ?: _viewEvents.post(OnboardingViewEvents.DisplayRegistrationStage(it.stage))
|
||||
}
|
||||
is RegistrationActionHandler.Result.RegistrationComplete -> onSessionCreated(
|
||||
|
@ -287,11 +287,11 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
authenticationDescription = awaitState().selectedAuthenticationState.description
|
||||
?: AuthenticationDescription.Register(AuthenticationDescription.AuthenticationType.Other)
|
||||
)
|
||||
RegistrationActionHandler.Result.StartRegistration -> _viewEvents.post(OnboardingViewEvents.DisplayStartRegistration)
|
||||
RegistrationActionHandler.Result.UnsupportedStage -> _viewEvents.post(OnboardingViewEvents.DisplayRegistrationFallback)
|
||||
is RegistrationActionHandler.Result.SendEmailSuccess -> _viewEvents.post(OnboardingViewEvents.OnSendEmailSuccess(it.email))
|
||||
is RegistrationActionHandler.Result.Error -> _viewEvents.post(OnboardingViewEvents.Failure(it.cause))
|
||||
RegistrationActionHandler.Result.MissingNextStage -> {
|
||||
RegistrationActionHandler.Result.StartRegistration -> _viewEvents.post(OnboardingViewEvents.DisplayStartRegistration)
|
||||
RegistrationActionHandler.Result.UnsupportedStage -> _viewEvents.post(OnboardingViewEvents.DisplayRegistrationFallback)
|
||||
is RegistrationActionHandler.Result.SendEmailSuccess -> _viewEvents.post(OnboardingViewEvents.OnSendEmailSuccess(it.email))
|
||||
is RegistrationActionHandler.Result.Error -> _viewEvents.post(OnboardingViewEvents.Failure(it.cause))
|
||||
RegistrationActionHandler.Result.MissingNextStage -> {
|
||||
_viewEvents.post(OnboardingViewEvents.Failure(IllegalStateException("No next registration stage found")))
|
||||
}
|
||||
}
|
||||
|
@ -368,8 +368,8 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
private fun handleUpdateSignMode(action: OnboardingAction.UpdateSignMode) {
|
||||
updateSignMode(action.signMode)
|
||||
when (action.signMode) {
|
||||
SignMode.SignUp -> handleRegisterAction(RegisterAction.StartRegistration)
|
||||
SignMode.SignIn -> startAuthenticationFlow()
|
||||
SignMode.SignUp -> handleRegisterAction(RegisterAction.StartRegistration)
|
||||
SignMode.SignIn -> startAuthenticationFlow()
|
||||
SignMode.SignInWithMatrixId -> _viewEvents.post(OnboardingViewEvents.OnSignModeSelected(SignMode.SignInWithMatrixId))
|
||||
SignMode.Unknown -> Unit
|
||||
}
|
||||
|
|
|
@ -44,11 +44,11 @@ class RegistrationActionHandler @Inject constructor(
|
|||
val result = registrationWizardActionDelegate.executeAction(action)
|
||||
return when {
|
||||
action.ignoresResult() -> Result.Ignored
|
||||
else -> when (result) {
|
||||
is RegistrationResult.Complete -> Result.RegistrationComplete(result.session)
|
||||
is RegistrationResult.NextStep -> processFlowResult(result, state)
|
||||
else -> when (result) {
|
||||
is RegistrationResult.Complete -> Result.RegistrationComplete(result.session)
|
||||
is RegistrationResult.NextStep -> processFlowResult(result, state)
|
||||
is RegistrationResult.SendEmailSuccess -> Result.SendEmailSuccess(result.email)
|
||||
is RegistrationResult.Error -> Result.Error(result.cause)
|
||||
is RegistrationResult.Error -> Result.Error(result.cause)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,9 +66,9 @@ class RegistrationActionHandler @Inject constructor(
|
|||
|
||||
private suspend fun handleNextStep(state: SelectedHomeserverState, flowResult: FlowResult): Result {
|
||||
return when {
|
||||
flowResult.registrationShouldFallback() -> Result.UnsupportedStage
|
||||
flowResult.registrationShouldFallback() -> Result.UnsupportedStage
|
||||
authenticationService.isRegistrationStarted() -> findNextStage(state, flowResult)
|
||||
else -> Result.StartRegistration
|
||||
else -> Result.StartRegistration
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ class RegistrationActionHandler @Inject constructor(
|
|||
state.hasSelectedMatrixOrg() && vectorFeatures.isOnboardingCombinedRegisterEnabled() -> flowResult.copy(
|
||||
missingStages = flowResult.missingStages.sortedWith(MatrixOrgRegistrationStagesComparator())
|
||||
)
|
||||
else -> flowResult
|
||||
else -> flowResult
|
||||
}
|
||||
return orderedResult.findNextRegistrationStage()
|
||||
?.let { Result.NextStage(it) }
|
||||
|
|
|
@ -36,15 +36,15 @@ class RegistrationWizardActionDelegate @Inject constructor(
|
|||
|
||||
suspend fun executeAction(action: RegisterAction): RegistrationResult {
|
||||
return when (action) {
|
||||
RegisterAction.StartRegistration -> resultOf { registrationWizard.getRegistrationFlow() }
|
||||
is RegisterAction.CaptchaDone -> resultOf { registrationWizard.performReCaptcha(action.captchaResponse) }
|
||||
is RegisterAction.AcceptTerms -> resultOf { registrationWizard.acceptTerms() }
|
||||
is RegisterAction.RegisterDummy -> resultOf { registrationWizard.dummy() }
|
||||
is RegisterAction.AddThreePid -> handleAddThreePid(registrationWizard, action)
|
||||
is RegisterAction.SendAgainThreePid -> resultOf { registrationWizard.sendAgainThreePid() }
|
||||
is RegisterAction.ValidateThreePid -> resultOf { registrationWizard.handleValidateThreePid(action.code) }
|
||||
RegisterAction.StartRegistration -> resultOf { registrationWizard.getRegistrationFlow() }
|
||||
is RegisterAction.CaptchaDone -> resultOf { registrationWizard.performReCaptcha(action.captchaResponse) }
|
||||
is RegisterAction.AcceptTerms -> resultOf { registrationWizard.acceptTerms() }
|
||||
is RegisterAction.RegisterDummy -> resultOf { registrationWizard.dummy() }
|
||||
is RegisterAction.AddThreePid -> handleAddThreePid(registrationWizard, action)
|
||||
is RegisterAction.SendAgainThreePid -> resultOf { registrationWizard.sendAgainThreePid() }
|
||||
is RegisterAction.ValidateThreePid -> resultOf { registrationWizard.handleValidateThreePid(action.code) }
|
||||
is RegisterAction.CheckIfEmailHasBeenValidated -> handleCheckIfEmailIsValidated(registrationWizard, action.delayMillis)
|
||||
is RegisterAction.CreateAccount -> resultOf {
|
||||
is RegisterAction.CreateAccount -> resultOf {
|
||||
registrationWizard.createAccount(
|
||||
action.username,
|
||||
action.password,
|
||||
|
@ -60,7 +60,7 @@ class RegistrationWizardActionDelegate @Inject constructor(
|
|||
onFailure = {
|
||||
when {
|
||||
action.threePid is RegisterThreePid.Email && it.is401() -> RegistrationResult.SendEmailSuccess(action.threePid.email)
|
||||
else -> RegistrationResult.Error(it)
|
||||
else -> RegistrationResult.Error(it)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -72,7 +72,7 @@ class RegistrationWizardActionDelegate @Inject constructor(
|
|||
onFailure = {
|
||||
when {
|
||||
it.is401() -> null // recursively continue to check with a delay
|
||||
else -> RegistrationResult.Error(it)
|
||||
else -> RegistrationResult.Error(it)
|
||||
}
|
||||
}
|
||||
) ?: handleCheckIfEmailIsValidated(registrationWizard, 10_000)
|
||||
|
@ -88,7 +88,7 @@ private inline fun resultOf(block: () -> MatrixRegistrationResult): Registration
|
|||
|
||||
private fun MatrixRegistrationResult.toRegistrationResult() = when (this) {
|
||||
is FlowResponse -> RegistrationResult.NextStep(flowResult)
|
||||
is Success -> RegistrationResult.Complete(session)
|
||||
is Success -> RegistrationResult.Complete(session)
|
||||
}
|
||||
|
||||
sealed interface RegistrationResult {
|
||||
|
@ -114,10 +114,10 @@ sealed interface RegisterAction {
|
|||
|
||||
fun RegisterAction.ignoresResult() = when (this) {
|
||||
is RegisterAction.SendAgainThreePid -> true
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
|
||||
fun RegisterAction.hasLoadingState() = when (this) {
|
||||
is RegisterAction.CheckIfEmailHasBeenValidated -> false
|
||||
else -> true
|
||||
else -> true
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ class FtueAuthVariant(
|
|||
|
||||
private fun handleOnboardingViewEvents(viewEvents: OnboardingViewEvents) {
|
||||
when (viewEvents) {
|
||||
is OnboardingViewEvents.OutdatedHomeserver -> {
|
||||
is OnboardingViewEvents.OutdatedHomeserver -> {
|
||||
MaterialAlertDialogBuilder(activity)
|
||||
.setTitle(R.string.login_error_outdated_homeserver_title)
|
||||
.setMessage(R.string.login_error_outdated_homeserver_warning_content)
|
||||
|
@ -223,14 +223,14 @@ class FtueAuthVariant(
|
|||
option = commonOption
|
||||
)
|
||||
}
|
||||
OnboardingViewEvents.OnHomeserverEdited -> activity.popBackstack()
|
||||
OnboardingViewEvents.OpenCombinedLogin -> onStartCombinedLogin()
|
||||
is OnboardingViewEvents.DeeplinkAuthenticationFailure -> onDeeplinkedHomeserverUnavailable(viewEvents)
|
||||
OnboardingViewEvents.DisplayRegistrationFallback -> displayFallbackWebDialog()
|
||||
is OnboardingViewEvents.DisplayRegistrationStage -> doStage(viewEvents.stage)
|
||||
OnboardingViewEvents.DisplayStartRegistration -> when {
|
||||
OnboardingViewEvents.OnHomeserverEdited -> activity.popBackstack()
|
||||
OnboardingViewEvents.OpenCombinedLogin -> onStartCombinedLogin()
|
||||
is OnboardingViewEvents.DeeplinkAuthenticationFailure -> onDeeplinkedHomeserverUnavailable(viewEvents)
|
||||
OnboardingViewEvents.DisplayRegistrationFallback -> displayFallbackWebDialog()
|
||||
is OnboardingViewEvents.DisplayRegistrationStage -> doStage(viewEvents.stage)
|
||||
OnboardingViewEvents.DisplayStartRegistration -> when {
|
||||
vectorFeatures.isOnboardingCombinedRegisterEnabled() -> openStartCombinedRegister()
|
||||
else -> openAuthLoginFragmentWithTag(FRAGMENT_REGISTRATION_STAGE_TAG)
|
||||
else -> openAuthLoginFragmentWithTag(FRAGMENT_REGISTRATION_STAGE_TAG)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue