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 aa4753b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 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
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class FtueAuthSplashFragment :
}
}

/** TCHAP Login with SSO */
/** TCHAP Login with SSO. */
private fun alreadyHaveAnAccountWithSSO() {
viewModel.handle(OnboardingAction.SplashAction.OnIAlreadyHaveAnAccount(onboardingFlow = OnboardingFlow.TchapSignInWithSSO))
}
Expand Down
10 changes: 5 additions & 5 deletions vector/src/main/res/layout/fragment_tchap_welcome.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
android:textColor="?vctr_content_primary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fragment_tchap_welcome_title" />
app:layout_constraintTop_toBottomOf="@id/fragment_tchap_welcome_title" />

<Button
android:id="@+id/loginSplashAC"
Expand All @@ -52,10 +52,10 @@
android:paddingVertical="10dp"
android:gravity="start|center_vertical"
android:text="@string/tchap_connection_ac"
app:layout_constraintBottom_toTopOf="@+id/loginSplashSubmit"
app:layout_constraintBottom_toTopOf="@id/loginSplashSubmit"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fragment_tchap_welcome_subtitle" />
app:layout_constraintTop_toBottomOf="@id/fragment_tchap_welcome_subtitle" />

<Button
android:id="@+id/loginSplashACHelp"
Expand All @@ -67,7 +67,7 @@
android:text="@string/tchap_connection_ac_help"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/loginSplashAC" />
app:layout_constraintTop_toBottomOf="@id/loginSplashAC" />

<Button
android:id="@+id/loginSplashAlreadyHaveAccount"
Expand All @@ -77,7 +77,7 @@
android:gravity="center"
android:text="@string/tchap_has_account_yes"
android:textColor="?colorPrimaryVariant"
app:layout_constraintBottom_toTopOf="@+id/loginSplashSubmit"
app:layout_constraintBottom_toTopOf="@id/loginSplashSubmit"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

Expand Down

0 comments on commit aa4753b

Please sign in to comment.