diff options
author | desperateCoder <echotodevnull@gmail.com> | 2021-02-07 17:19:15 +0300 |
---|---|---|
committer | desperateCoder <echotodevnull@gmail.com> | 2021-02-07 17:19:15 +0300 |
commit | b72131984a60982e3b59d8deb773b6dffe8e4ce9 (patch) | |
tree | d01fd205bddfc343c1de6fb2304550ba3e946902 /app | |
parent | 2bbc50657f61de140cdeda5e294ee51fd72f9d41 (diff) |
fixes #823 - made card propagation self-healing
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/CardPropagationDataProvider.java | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/CardPropagationDataProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/CardPropagationDataProvider.java index 422a11caa..aa5da8558 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/CardPropagationDataProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/CardPropagationDataProvider.java @@ -1,8 +1,11 @@ package it.niedermann.nextcloud.deck.persistence.sync.helpers.providers; +import android.annotation.SuppressLint; + import it.niedermann.nextcloud.deck.api.IResponseCallback; import it.niedermann.nextcloud.deck.model.Board; import it.niedermann.nextcloud.deck.model.Card; +import it.niedermann.nextcloud.deck.model.full.FullBoard; import it.niedermann.nextcloud.deck.model.full.FullCard; import it.niedermann.nextcloud.deck.model.full.FullStack; import it.niedermann.nextcloud.deck.model.propagation.CardUpdate; @@ -17,9 +20,42 @@ public class CardPropagationDataProvider extends CardDataProvider { @Override public void createOnServer(ServerAdapter serverAdapter, DataBaseAdapter dataBaseAdapter, long accountId, IResponseCallback<FullCard> responder, FullCard entity) { - Card card = entity.getCard(); - card.setStackId(stack.getId()); - serverAdapter.createCard(board.getId(), stack.getId(), card, responder); + // make sure, all ancestors are synced properly + if (board.getId() == null) { + serverAdapter.createBoard(board, new IResponseCallback<FullBoard>(responder.getAccount()) { + @Override + public void onResponse(FullBoard response) { + board.setId(response.getId()); + board.setEtag(response.getEtag()); + createOnServer(serverAdapter, dataBaseAdapter, accountId, responder, entity); + } + + @SuppressLint("MissingSuperCall") + @Override + public void onError(Throwable throwable) { + responder.onError(throwable); + } + }); + } else if (stack.getId() == null) { + serverAdapter.createStack(board, stack.getStack(), new IResponseCallback<FullStack>(responder.getAccount()) { + @Override + public void onResponse(FullStack response) { + stack.setId(response.getId()); + stack.setEtag(response.getEtag()); + createOnServer(serverAdapter, dataBaseAdapter, accountId, responder, entity); + } + + @SuppressLint("MissingSuperCall") + @Override + public void onError(Throwable throwable) { + responder.onError(throwable); + } + }); + } else { + Card card = entity.getCard(); + card.setStackId(stack.getId()); + serverAdapter.createCard(board.getId(), stack.getId(), card, responder); + } } |