Use response next batch when available. This prevents duplication.

This commit is contained in:
Danila Fedorin 2018-12-09 13:02:54 -08:00
parent 841d537168
commit 5ac8e8cb36
1 changed files with 4 additions and 1 deletions

View File

@ -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)