From 5ac8e8cb36c67c95dc1128c4385273681bff1c78 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sun, 9 Dec 2018 13:02:54 -0800 Subject: [PATCH] Use response next batch when available. This prevents duplication. --- src/Main.elm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Main.elm b/src/Main.elm index 7420373..40fdea6 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -73,7 +73,10 @@ updateLoginResponse model r = case r of updateSyncResponse : Model -> Result Http.Error SyncResponse -> (Model, Cmd Msg) updateSyncResponse model r = let - cmd = sync model.sync.nextBatch model.apiUrl <| Maybe.withDefault "" model.token + token = Maybe.withDefault "" model.token + nextBatch = Result.withDefault model.sync.nextBatch + <| Result.map .nextBatch r + cmd = sync nextBatch model.apiUrl token in case r of Ok sr -> ({ model | sync = mergeSyncResponse model.sync sr }, cmd)