From 8034f9a4002021c726a22b368bc4ae31d50937fa Mon Sep 17 00:00:00 2001 From: anvmn Date: Wed, 3 Apr 2024 17:37:23 +0300 Subject: [PATCH] Have Authority upload first and then WhatsApp Upload --- client/src/elm/SyncManager/Utils.elm | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/client/src/elm/SyncManager/Utils.elm b/client/src/elm/SyncManager/Utils.elm index 46aabdbd94..3e0187f80e 100644 --- a/client/src/elm/SyncManager/Utils.elm +++ b/client/src/elm/SyncManager/Utils.elm @@ -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. @@ -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 ) @@ -217,7 +208,7 @@ 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) ) @@ -225,6 +216,20 @@ determineSyncStatus activePage model = -- 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 ->