Skip to content

Commit

Permalink
Keep Showing Progress Dialog on while Survey Loads (#2768)
Browse files Browse the repository at this point in the history
* added progress dialog support

* flow changed to primitive

* format fix

---------

Co-authored-by: Gino Miceli <228050+gino-m@users.noreply.github.com>
  • Loading branch information
anandwana001 and gino-m authored Oct 3, 2024
1 parent 92c5392 commit ee40584
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ internal constructor(

private val _uiState: MutableStateFlow<UiState> = MutableStateFlow(UiState.FetchingSurveys)
val uiState: StateFlow<UiState> = _uiState.asStateFlow()
private var surveyActivationInProgress = false

var surveyActivationInProgress = false

init {
viewModelScope.launch {
Expand Down Expand Up @@ -86,8 +87,8 @@ internal constructor(
}
.fold(
onSuccess = {
_uiState.emit(UiState.SurveyActivated)
surveyActivationInProgress = false
_uiState.emit(UiState.SurveyActivated)
navigateToHomeScreen()
},
onFailure = { exception ->
Expand Down

0 comments on commit ee40584

Please sign in to comment.