diff options
author | desperateCoder <echotodevnull@gmail.com> | 2019-11-04 18:58:20 +0300 |
---|---|---|
committer | desperateCoder <echotodevnull@gmail.com> | 2019-11-04 18:58:20 +0300 |
commit | 90fe18d43f183717f90400d5fa8bacc8ec41a921 (patch) | |
tree | 4aec3b8c0a86baa9efd65438a02fa158c6f72604 /app | |
parent | 82a6a98e3cdb3178e7b909d8c7d4cac30a33a5c1 (diff) |
fixed (yet unreported) offline behaviour bug: cards were deleted if unsynced
Diffstat (limited to 'app')
3 files changed, 13 insertions, 9 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java index 7f9fc324e..3f5166d3a 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java @@ -442,9 +442,11 @@ public class SyncManager { } liveData.postValue(card); - new SyncHelper(serverAdapter, dataBaseAdapter, null) - .setResponseCallback(IResponseCallback.getDefaultResponseCallback(account)) - .doUpSyncFor(new CardDataProvider(null, board, stack)); + if (serverAdapter.hasInternetConnection()){ + new SyncHelper(serverAdapter, dataBaseAdapter, null) + .setResponseCallback(IResponseCallback.getDefaultResponseCallback(account)) + .doUpSyncFor(new CardDataProvider(null, board, stack)); + } }); return liveData; } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/CardDataProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/CardDataProvider.java index 4883c9cce..114464e35 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/CardDataProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/CardDataProvider.java @@ -248,11 +248,11 @@ public class CardDataProvider extends AbstractSyncDataProvider<FullCard> { List<FullCard> localCards = dataBaseAdapter.getFullCardsForStackDirectly(accountId, stack.getLocalId()); List<FullCard> delta = findDelta(entitiesFromServer, localCards); for (FullCard cardToDelete : delta) { + if (cardToDelete.getId() == null){ + // not pushed up yet so: + continue; + } if (cardToDelete.getStatus() == DBStatus.LOCAL_MOVED.getId()){ - if (cardToDelete.getId() == null){ - // not pushed up yet so: - continue; - } else { //only delete, if the card isn't availible on server anymore. serverAdapter.getCard(board.getId(), stack.getId(), cardToDelete.getId(), new IResponseCallback<FullCard>(new Account(accountId)){ @Override @@ -268,7 +268,6 @@ public class CardDataProvider extends AbstractSyncDataProvider<FullCard> { } } }); - } continue; } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/LabelDataProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/LabelDataProvider.java index 0fed5115f..016ff8df8 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/LabelDataProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/LabelDataProvider.java @@ -80,7 +80,10 @@ public class LabelDataProvider extends AbstractSyncDataProvider<Label> { public void handleDeletes(ServerAdapter serverAdapter, DataBaseAdapter dataBaseAdapter, long accountId, List<Label> entitiesFromServer) { List<Label> deletedLabels = findDelta(labels, dataBaseAdapter.getFullBoardByLocalIdDirectly(accountId, board.getLocalId()).getLabels()); for (Label deletedLabel : deletedLabels) { - dataBaseAdapter.deleteLabelPhysically(deletedLabel); + if (deletedLabel.getId()!=null){ + // preserve new, unsynced card. + dataBaseAdapter.deleteLabelPhysically(deletedLabel); + } } } } |