Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocked state to CurrentSyncJobstatus. #2607

Merged
merged 3 commits into from
Jul 9, 2024
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 @@ -189,7 +189,14 @@ class PatientListFragment : Fragment() {
patientListViewModel.searchPatientsByName(searchView.query.toString().trim())
fadeOutTopBanner(currentSyncJobStatus)
}
CurrentSyncJobStatus.Cancelled -> TODO()
is CurrentSyncJobStatus.Cancelled -> {
Timber.i("Sync: Cancelled")
fadeOutTopBanner(currentSyncJobStatus)
}
is CurrentSyncJobStatus.Blocked -> {
Timber.i("Sync: Blocked")
fadeOutTopBanner(currentSyncJobStatus)
}
}
}

Expand Down Expand Up @@ -220,7 +227,14 @@ class PatientListFragment : Fragment() {
patientListViewModel.searchPatientsByName(searchView.query.toString().trim())
fadeOutTopBanner(periodicSyncJobStatus.currentSyncJobStatus)
}
CurrentSyncJobStatus.Cancelled -> TODO()
is CurrentSyncJobStatus.Cancelled -> {
Timber.i("Sync: Cancelled")
fadeOutTopBanner(periodicSyncJobStatus.currentSyncJobStatus)
}
is CurrentSyncJobStatus.Blocked -> {
Timber.i("Sync: Blocked")
fadeOutTopBanner(periodicSyncJobStatus.currentSyncJobStatus)
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion engine/src/main/java/com/google/android/fhir/sync/Sync.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.work.ExistingWorkPolicy
import androidx.work.OneTimeWorkRequest
import androidx.work.PeriodicWorkRequest
import androidx.work.WorkInfo
import androidx.work.WorkInfo.State.BLOCKED
import androidx.work.WorkInfo.State.CANCELLED
import androidx.work.WorkInfo.State.ENQUEUED
import androidx.work.WorkInfo.State.FAILED
Expand Down Expand Up @@ -309,7 +310,7 @@ object Sync {
}
?: error("Inconsistent terminal syncJobStatus.")
CANCELLED -> Cancelled
else -> error("Inconsistent WorkInfo.State: $workInfoState.")
BLOCKED -> CurrentSyncJobStatus.Blocked
}

/**
Expand All @@ -328,6 +329,7 @@ object Sync {
?: Enqueued
}
CANCELLED -> Cancelled
BLOCKED -> CurrentSyncJobStatus.Blocked
else -> error("Inconsistent WorkInfo.State in periodic sync : $workInfoState.")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ sealed class CurrentSyncJobStatus {

/** State indicating that the synchronization operation is canceled. */
object Cancelled : CurrentSyncJobStatus()

/** State indicating that the synchronization operation is blocked. */
data object Blocked : CurrentSyncJobStatus()
}

/**
Expand Down
Loading