android-fhir
android-fhir copied to clipboard
Demo app - last sync time updates even when sync fails
Describe the bug The app is in a state where sync appears to fail 100% of the time. The "Last sync" timestamp in the menu updates after failure.
Component Demo app
To Reproduce Steps to reproduce the behavior:
- Make sync fail. I did this by creating a patient on the server, syncing to the app, deleting the patient from the server, and editing the same patient on the app.
- Open menu and select Sync
Expected behavior "Last sync" usually means "last successfully synced", so I do not expect the timestamp to update on failure.
Screenshots If applicable, add screenshots to help explain your problem.
https://user-images.githubusercontent.com/7772901/193365131-a316ef68-cd07-4d4a-9122-564bc72e8273.mp4
Smartphone (please complete the following information):
- Device: Pixel 4
FhirSynchronizer
private suspend fun setSyncState(result: Result): Result {
datastoreUtil.writeLastSyncTimestamp(result.timestamp)
when (result) {
is Result.Success -> setSyncState(State.Finished(result))
is Result.Error -> setSyncState(State.Failed(result))
}
return result
}
@jingtang10, any thoughts if this change should be included in the backlog?
@MJ1998 can you take a look at this?
@williamito
The last sync timestamp reflects the most recent sync attempt, even if unsuccessful.
I think it should be updated because its possible that the sync was partially successful.
Maybe we should include a sync status in the menu, like Successful or Failed ?