diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java index eafa8079e..8fc756ad2 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java @@ -183,7 +183,7 @@ public class ActFmSyncThread { } } - private final Runnable defaultRefreshRunnable = new Runnable() { + public static final Runnable DEFAULT_REFRESH_RUNNABLE = new Runnable() { @Override public void run() { Intent refresh = new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH); @@ -213,10 +213,10 @@ public class ActFmSyncThread { if (timeForBackgroundSync()) { repopulateQueueFromOutstandingTables(); - enqueueMessage(BriefMe.instantiateBriefMeForClass(TaskListMetadata.class, NameMaps.PUSHED_AT_TASK_LIST_METADATA), defaultRefreshRunnable); - enqueueMessage(BriefMe.instantiateBriefMeForClass(Task.class, NameMaps.PUSHED_AT_TASKS), defaultRefreshRunnable); - enqueueMessage(BriefMe.instantiateBriefMeForClass(TagData.class, NameMaps.PUSHED_AT_TAGS), defaultRefreshRunnable); - enqueueMessage(BriefMe.instantiateBriefMeForClass(User.class, NameMaps.PUSHED_AT_USERS), defaultRefreshRunnable); + enqueueMessage(BriefMe.instantiateBriefMeForClass(TaskListMetadata.class, NameMaps.PUSHED_AT_TASK_LIST_METADATA), DEFAULT_REFRESH_RUNNABLE); + enqueueMessage(BriefMe.instantiateBriefMeForClass(Task.class, NameMaps.PUSHED_AT_TASKS), DEFAULT_REFRESH_RUNNABLE); + enqueueMessage(BriefMe.instantiateBriefMeForClass(TagData.class, NameMaps.PUSHED_AT_TAGS), DEFAULT_REFRESH_RUNNABLE); + enqueueMessage(BriefMe.instantiateBriefMeForClass(User.class, NameMaps.PUSHED_AT_USERS), DEFAULT_REFRESH_RUNNABLE); setTimeForBackgroundSync(false); } @@ -272,7 +272,7 @@ public class ActFmSyncThread { try { Runnable r = pendingCallbacks.remove(message); if (r != null) { - if (r == defaultRefreshRunnable) { + if (r == DEFAULT_REFRESH_RUNNABLE) { if (didDefaultRefreshThisLoop) continue; didDefaultRefreshThisLoop = true; diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncWaitingPool.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncWaitingPool.java index c0e6dca36..37e93b1ec 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncWaitingPool.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncWaitingPool.java @@ -35,7 +35,7 @@ public class ActFmSyncWaitingPool { return; AndroidUtilities.sleepDeep(WAIT_TIME); while (!pendingMessages.isEmpty()) { - ActFmSyncThread.getInstance().enqueueMessage(pendingMessages.remove(0), null); + ActFmSyncThread.getInstance().enqueueMessage(pendingMessages.remove(0), ActFmSyncThread.DEFAULT_REFRESH_RUNNABLE); } } }; diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ReplayOutstandingEntries.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ReplayOutstandingEntries.java index a813434f1..260f624ac 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ReplayOutstandingEntries.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ReplayOutstandingEntries.java @@ -59,6 +59,10 @@ public class ReplayOutstandingEntries(id, modelClass, dao, outstandingDao), null); } + protected boolean shouldSaveModel(T model) { + return true; + } + private void processItem(long id, OE instance, TodorooCursor outstanding) { try { T model = modelClass.newInstance(); @@ -79,10 +83,12 @@ public class ReplayOutstandingEntries 0 && !afterErrors) { - enqueueChangesHappenedMessage(id); + if (count > 0 && !afterErrors) { + enqueueChangesHappenedMessage(id); + } } outstanding.moveToPrevious(); // Move back one to undo the last iteration of the for loop diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ReplayTaskListMetadataOutstanding.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ReplayTaskListMetadataOutstanding.java index 6b7ccaa58..7f3f96b70 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ReplayTaskListMetadataOutstanding.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ReplayTaskListMetadataOutstanding.java @@ -11,6 +11,14 @@ public class ReplayTaskListMetadataOutstanding extends ReplayOutstandingEntries< super(TaskListMetadata.class, NameMaps.TABLE_ID_TASK_LIST_METADATA, dao, outstandingDao, afterErrors); } + @Override + protected boolean shouldSaveModel(TaskListMetadata model) { + if (model.containsNonNullValue(TaskListMetadata.TASK_IDS) && + TaskListMetadata.taskIdsIsEmpty(model.getValue(TaskListMetadata.TASK_IDS))) + return false; + return true; + } + @Override protected void enqueueChangesHappenedMessage(long id) { // Do nothing