From ae802dea315b594f9c02209b4bd681cf5a5635c8 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 23 Sep 2022 15:56:55 +0200 Subject: [PATCH] Avoid using ActiveSessionHolder in a Fragment. Use the userId from `state.personalizationState` --- .../ftueauth/FtueAuthAccountCreatedFragment.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthAccountCreatedFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthAccountCreatedFragment.kt index a53ca52e85..2089dc5ad0 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthAccountCreatedFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthAccountCreatedFragment.kt @@ -26,21 +26,17 @@ import androidx.core.view.isVisible import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R import im.vector.app.core.animations.play -import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.utils.isAnimationEnabled import im.vector.app.core.utils.styleMatchingText import im.vector.app.databinding.FragmentFtueAccountCreatedBinding import im.vector.app.features.onboarding.OnboardingAction import im.vector.app.features.onboarding.OnboardingViewEvents import im.vector.app.features.onboarding.OnboardingViewState -import javax.inject.Inject @AndroidEntryPoint class FtueAuthAccountCreatedFragment : AbstractFtueAuthFragment() { - @Inject lateinit var activeSessionHolder: ActiveSessionHolder - private var hasPlayedConfetti = false override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueAccountCreatedBinding { @@ -53,15 +49,15 @@ class FtueAuthAccountCreatedFragment : } private fun setupViews() { - val userId = activeSessionHolder.getActiveSession().myUserId - val subtitle = getString(R.string.ftue_account_created_subtitle, userId).toSpannable().styleMatchingText(userId, Typeface.BOLD) - views.accountCreatedSubtitle.text = subtitle views.accountCreatedPersonalize.debouncedClicks { viewModel.handle(OnboardingAction.PersonalizeProfile) } views.accountCreatedTakeMeHome.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnTakeMeHome)) } views.accountCreatedTakeMeHomeCta.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnTakeMeHome)) } } override fun updateWithState(state: OnboardingViewState) { + val userId = state.personalizationState.userId + val subtitle = getString(R.string.ftue_account_created_subtitle, userId).toSpannable().styleMatchingText(userId, Typeface.BOLD) + views.accountCreatedSubtitle.text = subtitle val canPersonalize = state.personalizationState.supportsPersonalization() views.personalizeButtonGroup.isVisible = canPersonalize views.takeMeHomeButtonGroup.isVisible = !canPersonalize