Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Properly update Done button once srs submission fails (EXPOSUREAPP-14419) #5754

Merged
merged 1 commit into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ class SrsSymptomsIntroductionFragment : Fragment(R.layout.fragment_submission_sy
updateButtons(it)
}

viewModel.showLoadingIndicator.observe(viewLifecycleOwner) { binding.symptomButtonNext.isLoading = it }
viewModel.showLoadingIndicator.observe(viewLifecycleOwner) {
binding.symptomButtonNext.isLoading = it.first
if (!it.first) updateButtons(it.second)
}

viewModel.events.observe(viewLifecycleOwner) {
when (it) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SrsSymptomsIntroductionViewModel @AssistedInject constructor(
) : CWAViewModel(dispatcherProvider) {

val events = SingleLiveEvent<SrsSymptomsIntroductionNavigation>()
val showLoadingIndicator = SingleLiveEvent<Boolean>()
val showLoadingIndicator = SingleLiveEvent<Pair<Boolean, Symptoms.Indication?>>()

private val symptomIndicationInternal = MutableStateFlow<Symptoms.Indication?>(null)
val symptomIndication = symptomIndicationInternal.asLiveData(context = dispatcherProvider.Default)
Expand All @@ -49,7 +49,7 @@ class SrsSymptomsIntroductionViewModel @AssistedInject constructor(
}

fun onWarningClicked() {
showLoadingIndicator.postValue(true)
showLoadingIndicator.postValue(Pair(true, symptomIndicationInternal.value))
when (symptomIndicationInternal.value) {
Symptoms.Indication.NEGATIVE -> {
submitSRS(Symptoms.Indication.NEGATIVE)
Expand Down Expand Up @@ -86,7 +86,7 @@ class SrsSymptomsIntroductionViewModel @AssistedInject constructor(
else -> events.postValue(SrsSymptomsIntroductionNavigation.Error(e))
}
} finally {
showLoadingIndicator.postValue(false)
showLoadingIndicator.postValue(Pair(false, symptomsIndication))
}
}

Expand Down