Skip to content

Commit

Permalink
Merge pull request #1101 from TIP-Global-Health/issue-p-3127
Browse files Browse the repository at this point in the history
[Hotfix]: Elm Sync - revert upload order, so HC content is uploaded before WhatsApp records
  • Loading branch information
anvmn authored Apr 3, 2024
2 parents 8faffda + 8034f9a commit 6024557
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions client/src/elm/SyncManager/Utils.elm
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,6 @@ determineSyncStatus activePage model =
noChange

SyncUploadGeneral record ->
if record.indexDbRemoteData == RemoteData.Success Nothing then
-- We tried to fetch entities for upload from IndexDB,
-- but there we non matching the query.
( SyncUploadWhatsApp emptyUploadRec, syncInfoAuthorities )

else
noChange

SyncUploadWhatsApp record ->
if record.indexDbRemoteData == RemoteData.Success Nothing then
-- We tried to fetch entities for upload from IndexDB,
-- but there we non matching the query.
Expand All @@ -199,7 +190,7 @@ determineSyncStatus activePage model =
case ( syncInfoAuthorities, record.indexDbRemoteData ) of
( Nothing, _ ) ->
-- There are no authorities, so we can set the next status.
( SyncDownloadGeneral RemoteData.NotAsked
( SyncUploadWhatsApp emptyUploadRec
, syncInfoAuthorities
)

Expand All @@ -217,14 +208,28 @@ determineSyncStatus activePage model =
-- We've reached the last element,
-- so reset authorities zipper to first element,
-- and rotate to the next status.
( SyncDownloadGeneral RemoteData.NotAsked
( SyncUploadWhatsApp emptyUploadRec
, Just (Zipper.first zipper)
)

_ ->
-- Still have data to upload.
noChange

-- It's important to have Whatsapp uploaded after Authority upload
-- has completed, because Whatsapp record may refer to person
-- that's pending upload at Authority.
SyncUploadWhatsApp record ->
if record.indexDbRemoteData == RemoteData.Success Nothing then
-- We tried to fetch entities for upload from IndexDB,
-- but there we non matching the query.
( SyncDownloadGeneral RemoteData.NotAsked
, syncInfoAuthorities
)

else
noChange

SyncDownloadGeneral webData ->
case webData of
RemoteData.Success data ->
Expand Down

0 comments on commit 6024557

Please sign in to comment.