Analytics: ViewEvent sent before the View is ready.

This commit is contained in:
Benoit Marty 2021-12-07 13:07:58 +01:00
parent d0b62738e1
commit eba5aa94ce
3 changed files with 11 additions and 3 deletions

View file

@ -271,6 +271,7 @@ class HomeActivity :
if (isFirstCreation()) {
handleIntent(intent)
}
homeActivityViewModel.handle(HomeActivityViewActions.ViewStarted)
}
private fun handleShowAnalyticsOptIn() {

View file

@ -18,6 +18,7 @@ package im.vector.app.features.home
import im.vector.app.core.platform.VectorViewModelAction
sealed class HomeActivityViewActions : VectorViewModelAction {
object PushPromptHasBeenReviewed : HomeActivityViewActions()
sealed interface HomeActivityViewActions : VectorViewModelAction {
object ViewStarted : HomeActivityViewActions
object PushPromptHasBeenReviewed : HomeActivityViewActions
}

View file

@ -72,10 +72,13 @@ class HomeActivityViewModel @AssistedInject constructor(
companion object : MavericksViewModelFactory<HomeActivityViewModel, HomeActivityViewState> by hiltMavericksViewModelFactory()
private var isInitialized = false
private var checkBootstrap = false
private var onceTrusted = false
init {
private fun initialize() {
if (isInitialized) return
isInitialized = true
cleanupFiles()
observeInitialSync()
checkSessionPushIsOn()
@ -257,6 +260,9 @@ class HomeActivityViewModel @AssistedInject constructor(
HomeActivityViewActions.PushPromptHasBeenReviewed -> {
vectorPreferences.setDidAskUserToEnableSessionPush()
}
HomeActivityViewActions.ViewStarted -> {
initialize()
}
}.exhaustive
}
}