From 1dd46d3700a2c7b260124de194d3adf9e4c7a4d1 Mon Sep 17 00:00:00 2001 From: yostyle Date: Tue, 17 Sep 2024 01:05:34 +0200 Subject: [PATCH] Refactoring --- .../onboarding/OnboardingViewModel.kt | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt index 0132f8b37c..bd2c9a941d 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt @@ -179,7 +179,7 @@ class OnboardingViewModel @AssistedInject constructor( override fun handle(action: OnboardingAction) { when (action) { - is OnboardingAction.LoginWithSSO -> handleLoginWithSSO(action) + is OnboardingAction.LoginWithSSO -> tchap.handleLoginWithSSO(action) is OnboardingAction.SplashAction -> handleSplashAction(action) is OnboardingAction.UpdateUseCase -> handleUpdateUseCase(action) OnboardingAction.ResetUseCase -> resetUseCase() @@ -210,20 +210,6 @@ class OnboardingViewModel @AssistedInject constructor( } } - private fun handleLoginWithSSO(action: OnboardingAction.LoginWithSSO) { - currentJob = viewModelScope.launch { - when (val result = getPlatformTask.execute(Params(action.email))) { - is GetPlatformResult.Success -> { - val homeServerUrl = stringProvider.getString(R.string.server_url_prefix) + result.platform.hs - handleHomeserverChange(OnboardingAction.HomeServerChange.EditHomeServer(homeServerUrl)) - } - is GetPlatformResult.Failure -> { - // Nothin to do. - } - } - } - } - private fun handleUserNameEntered(action: OnboardingAction.UserNameEnteredAction) { when (action) { is OnboardingAction.UserNameEnteredAction.Login -> maybeUpdateHomeserver(action.userId) @@ -1024,6 +1010,10 @@ class OnboardingViewModel @AssistedInject constructor( } } + fun handleLoginWithSSO(action: OnboardingAction.LoginWithSSO) { + startTchapAuthenticationFlow(action.email) {} + } + fun startResetPasswordFlow(email: String, onSuccess: () -> Unit) { startTchapAuthenticationFlow(email) { this@OnboardingViewModel.startResetPasswordFlow(email, onSuccess)