Skip to content
Snippets Groups Projects
Unverified Commit b83b9a53 authored by Mohamed's avatar Mohamed Committed by GitHub
Browse files

Set auto submission in onStop to cover all cases (#3050)

parent 01a40c85
No related branches found
No related tags found
No related merge requests found
......@@ -81,6 +81,11 @@ class CheckInsConsentFragment : Fragment(R.layout.check_ins_consent_fragment), A
}
}
override fun onStop() {
super.onStop()
viewModel.setAutoSubmission()
}
private fun showSkipDialog() {
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.trace_location_attendee_consent_dialog_title)
......
......@@ -51,8 +51,6 @@ class CheckInsConsentViewModel @AssistedInject constructor(
resetPreviousSubmissionConsents()
Timber.d("Navigate to shareSelectedCheckIns")
autoSubmission.updateMode(AutoSubmission.Mode.MONITOR)
// Update CheckIns for new submission
val idsWithConsent = selectedSetFlow.value
checkInRepository.updateSubmissionConsents(
......@@ -75,7 +73,6 @@ class CheckInsConsentViewModel @AssistedInject constructor(
resetPreviousSubmissionConsents()
Timber.d("Navigate to doNotShareCheckIns")
autoSubmission.updateMode(AutoSubmission.Mode.MONITOR)
val event = if (coronaTest.first().isViewed) {
Timber.d("Navigate to SubmissionResultReadyFragment")
CheckInsConsentNavigation.ToSubmissionResultReadyFragment
......@@ -86,6 +83,11 @@ class CheckInsConsentViewModel @AssistedInject constructor(
events.postValue(event)
}
fun setAutoSubmission() {
Timber.d("setAutoSubmission")
autoSubmission.updateMode(AutoSubmission.Mode.MONITOR)
}
fun onCloseClick() = launch {
val event = if (coronaTest.first().isViewed) {
Timber.d("openSkipDialog")
......
......@@ -15,6 +15,7 @@ import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.just
import io.mockk.mockk
import io.mockk.verify
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.flowOf
import okio.ByteString.Companion.decodeBase64
......@@ -288,7 +289,6 @@ class CheckInsConsentViewModelTest : BaseTest() {
coVerify {
checkInRepository.updateSubmissionConsents(any(), false)
autoSubmission.updateMode(AutoSubmission.Mode.MONITOR)
checkInRepository.updateSubmissionConsents(any(), true)
}
}
......@@ -303,7 +303,6 @@ class CheckInsConsentViewModelTest : BaseTest() {
coVerify {
checkInRepository.updateSubmissionConsents(any(), false)
autoSubmission.updateMode(AutoSubmission.Mode.MONITOR)
checkInRepository.updateSubmissionConsents(any(), true)
}
}
......@@ -318,7 +317,6 @@ class CheckInsConsentViewModelTest : BaseTest() {
coVerify {
checkInRepository.updateSubmissionConsents(any(), false)
autoSubmission.updateMode(AutoSubmission.Mode.MONITOR)
}
}
......@@ -332,10 +330,15 @@ class CheckInsConsentViewModelTest : BaseTest() {
coVerify {
checkInRepository.updateSubmissionConsents(any(), false)
autoSubmission.updateMode(AutoSubmission.Mode.MONITOR)
}
}
@Test
fun setAutoSubmission() {
createViewModel().setAutoSubmission()
verify { autoSubmission.updateMode(AutoSubmission.Mode.MONITOR) }
}
private fun createViewModel() = CheckInsConsentViewModel(
savedState = savedState,
dispatcherProvider = TestDispatcherProvider(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment