diff --git a/android/engine/src/main/java/org/smartregister/fhircore/engine/sync/SyncBroadcaster.kt b/android/engine/src/main/java/org/smartregister/fhircore/engine/sync/SyncBroadcaster.kt index 7047b9328b..7eb2ab584f 100644 --- a/android/engine/src/main/java/org/smartregister/fhircore/engine/sync/SyncBroadcaster.kt +++ b/android/engine/src/main/java/org/smartregister/fhircore/engine/sync/SyncBroadcaster.kt @@ -23,6 +23,7 @@ import androidx.work.OneTimeWorkRequestBuilder import androidx.work.WorkManager import com.google.android.fhir.FhirEngine import com.google.android.fhir.sync.CurrentSyncJobStatus +import com.google.android.fhir.sync.LastSyncJobStatus import com.google.android.fhir.sync.PeriodicSyncConfiguration import com.google.android.fhir.sync.PeriodicSyncJobStatus import com.google.android.fhir.sync.RepeatInterval @@ -104,7 +105,11 @@ constructor( ) { this.onEach { syncListenerManager.onSyncListeners.forEach { onSyncListener -> - onSyncListener.onSync(it.currentSyncJobStatus) + onSyncListener.onSync( + if (it.lastSyncJobStatus != null) { + CurrentSyncJobStatus.Succeeded((it.lastSyncJobStatus as LastSyncJobStatus).timestamp) + } else it.currentSyncJobStatus, + ) } } .catch { throwable -> Timber.e("Encountered an error during periodic sync:", throwable) }