diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java index 70dad4072..81844b58d 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java @@ -600,8 +600,16 @@ public final class ActFmSyncService { public void pushTagOrderingImmediately(TagData tagData) { if (tagOrderQueue.contains(tagData.getId())) { tagOrderQueue.remove(tagData.getId()); - pushTagOrdering(tagData); } + pushTagOrdering(tagData); + } + + public boolean cancelTagOrderingPush(long tagDataId) { + if (tagOrderQueue.contains(tagDataId)) { + tagOrderQueue.remove(tagDataId); + return true; + } + return false; } private void pushTagOrdering(TagData tagData) { diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java index c0f230539..ae0748632 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java @@ -452,8 +452,8 @@ public class ActFmSyncV2Provider extends SyncV2Provider { if(!noRemoteId) { actFmSyncService.waitUntilEmpty(); - actFmSyncService.pushTagOrderingImmediately(tagData); - fetchTasksForTag(tagData, manual, callback, finisher); + boolean orderPushQueued = actFmSyncService.cancelTagOrderingPush(tagData.getId()); + fetchTasksForTag(tagData, manual, orderPushQueued, callback, finisher); fetchUpdatesForTag(tagData, manual, callback, finisher); } @@ -494,7 +494,7 @@ public class ActFmSyncV2Provider extends SyncV2Provider { actFmSyncService.fetchTag(tagData); if(noRemoteId) { - fetchTasksForTag(tagData, manual, callback, finisher); + fetchTasksForTag(tagData, manual, true, callback, finisher); fetchUpdatesForTag(tagData, manual, callback, finisher); } @@ -527,14 +527,17 @@ public class ActFmSyncV2Provider extends SyncV2Provider { }); } - private void fetchTasksForTag(final TagData tagData, boolean manual, final SyncResultCallback callback, + private void fetchTasksForTag(final TagData tagData, boolean manual, final boolean pushOrder, final SyncResultCallback callback, final AtomicInteger finisher) { actFmSyncService.fetchTasksForTag(tagData, manual, new Runnable() { @Override public void run() { pushQueuedTasksByTag(tagData, callback, finisher); - actFmSyncService.fetchTagOrder(tagData); + if (pushOrder) + actFmSyncService.pushTagOrderingImmediately(tagData); + else + actFmSyncService.fetchTagOrder(tagData); callback.incrementProgress(30); if(finisher.decrementAndGet() == 0)