Skip to content

Commit

Permalink
reusing the PostViewEvent action as a way to avoid redundant duplicat…
Browse files Browse the repository at this point in the history
…ed actions/events
  • Loading branch information
ouchadam committed Feb 15, 2022
1 parent e0f99e3 commit 3f9e7a7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,4 @@ sealed class OnboardingAction : VectorViewModelAction {
data class PostViewEvent(val viewEvent: OnboardingViewEvents) : OnboardingAction()

data class UserAcceptCertificate(val fingerprint: Fingerprint) : OnboardingAction()

object TakeMeHome : OnboardingAction()
object PersonalizeProfile : OnboardingAction()
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ class OnboardingViewModel @AssistedInject constructor(
is OnboardingAction.UserAcceptCertificate -> handleUserAcceptCertificate(action)
OnboardingAction.ClearHomeServerHistory -> handleClearHomeServerHistory()
is OnboardingAction.PostViewEvent -> _viewEvents.post(action.viewEvent)
OnboardingAction.PersonalizeProfile -> _viewEvents.post(OnboardingViewEvents.OnPersonalizeProfile)
OnboardingAction.TakeMeHome -> _viewEvents.post(OnboardingViewEvents.OnTakeMeHome)
}.exhaustive
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import im.vector.app.R
import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.databinding.FragmentFtueAccountCreatedBinding
import im.vector.app.features.onboarding.OnboardingAction
import im.vector.app.features.onboarding.OnboardingViewEvents
import javax.inject.Inject

class FtueAuthAccountCreatedFragment @Inject constructor(
Expand All @@ -41,16 +42,16 @@ class FtueAuthAccountCreatedFragment @Inject constructor(

private fun setupViews() {
views.accountCreatedSubtitle.text = getString(R.string.ftue_account_created_subtitle, activeSessionHolder.getActiveSession().myUserId)
views.accountCreatedPersonalize.setOnClickListener { viewModel.handle(OnboardingAction.PersonalizeProfile) }
views.accountCreatedTakeMeHome.setOnClickListener { viewModel.handle(OnboardingAction.TakeMeHome) }
views.accountCreatedPersonalize.setOnClickListener { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnPersonalizeProfile)) }
views.accountCreatedTakeMeHome.setOnClickListener { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnTakeMeHome)) }
}

override fun resetViewModel() {
// Nothing to do
}

override fun onBackPressed(toolbarButton: Boolean): Boolean {
viewModel.handle(OnboardingAction.TakeMeHome)
viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnTakeMeHome))
return false
}
}

0 comments on commit 3f9e7a7

Please sign in to comment.