diff --git a/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorFragment.kt b/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorFragment.kt index 9a68a43878..ac4ef63671 100644 --- a/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorFragment.kt @@ -55,11 +55,15 @@ class SurveySelectorFragment : AbstractFragment(), BackPressListener { showProgressDialog() } UiState.SurveyActivated -> { - dismissProgressDialog() + if (!viewModel.surveyActivationInProgress) { + dismissProgressDialog() + } } is UiState.SurveyListAvailable -> { handleSurveyListUpdated(uiState.surveys) - dismissProgressDialog() + if (!viewModel.surveyActivationInProgress) { + dismissProgressDialog() + } } is UiState.Error -> { dismissProgressDialog() diff --git a/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorViewModel.kt b/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorViewModel.kt index c145b638da..6ac07d7f6b 100644 --- a/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorViewModel.kt +++ b/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorViewModel.kt @@ -53,7 +53,8 @@ internal constructor( private val _uiState: MutableStateFlow = MutableStateFlow(UiState.FetchingSurveys) val uiState: StateFlow = _uiState.asStateFlow() - private var surveyActivationInProgress = false + + var surveyActivationInProgress = false init { viewModelScope.launch { @@ -86,8 +87,8 @@ internal constructor( } .fold( onSuccess = { - _uiState.emit(UiState.SurveyActivated) surveyActivationInProgress = false + _uiState.emit(UiState.SurveyActivated) navigateToHomeScreen() }, onFailure = { exception ->