Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
yostyle committed Sep 16, 2024
1 parent 4656116 commit 8b1476a
Showing 1 changed file with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8b1476a

Please sign in to comment.