From f5e64b8b80512ba7d14a14d7159a877e789a4738 Mon Sep 17 00:00:00 2001 From: Martin Ndegwa Date: Sat, 16 Nov 2024 20:03:33 +0300 Subject: [PATCH] =?UTF-8?q?Fix=20Home=20Register=20not=20refreshing=20afte?= =?UTF-8?q?r=20initial=20sync=20=F0=9F=90=9B=20(#3616)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../smartregister/fhircore/engine/sync/SyncBroadcaster.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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) }