mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 18:05:36 +03:00
Avoid using ActiveSessionHolder in a Fragment. Use the userId from state.personalizationState
This commit is contained in:
parent
b5eb15c7e3
commit
ae802dea31
1 changed files with 3 additions and 7 deletions
|
@ -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<FragmentFtueAccountCreatedBinding>() {
|
||||
|
||||
@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
|
||||
|
|
Loading…
Reference in a new issue