persisting the use case at the point of session creation

- this ensures we have a unique session or account id to store the selection against in case we support multi account in the future
This commit is contained in:
Adam Brown 2022-01-21 13:07:57 +00:00
parent 0a7c421faa
commit c4ac03949c
2 changed files with 9 additions and 12 deletions

View file

@ -464,22 +464,14 @@ class OnboardingViewModel @AssistedInject constructor(
}
private fun handleUpdateUseCase(action: OnboardingAction.UpdateUseCase) {
viewModelScope.launch {
onboardingStore.setUseCase(action.useCase)
analyticsTracker.updateUserProperties(
Identity(ftueUseCaseSelection = action.useCase.toTrackingValue())
)
}
setState { copy(useCase = action.useCase) }
analyticsTracker.updateUserProperties(Identity(ftueUseCaseSelection = action.useCase.toTrackingValue()))
_viewEvents.post(OnboardingViewEvents.OpenServerSelection)
}
private fun resetUseCase() {
viewModelScope.launch {
onboardingStore.resetUseCase()
analyticsTracker.updateUserProperties(
Identity(ftueUseCaseSelection = null)
)
}
setState { copy(useCase = null) }
analyticsTracker.updateUserProperties(Identity(ftueUseCaseSelection = null))
}
private fun handleUpdateServerType(action: OnboardingAction.UpdateServerType) {
@ -760,6 +752,9 @@ class OnboardingViewModel @AssistedInject constructor(
}
private suspend fun onSessionCreated(session: Session) {
awaitState().useCase?.let { useCase ->
onboardingStore.setUseCase(useCase)
}
activeSessionHolder.setActiveSession(session)
authenticationService.reset()

View file

@ -40,6 +40,8 @@ data class OnboardingViewState(
@PersistState
val serverType: ServerType = ServerType.Unknown,
@PersistState
val useCase: FtueUseCase? = null,
@PersistState
val signMode: SignMode = SignMode.Unknown,
@PersistState
val resetPasswordEmail: String? = null,