From f765dd17e011e3f1da54edbf73962a23abcb970c Mon Sep 17 00:00:00 2001 From: Tim Su Date: Tue, 17 Aug 2010 14:13:34 -0700 Subject: [PATCH] Fixed issues with producteev and synchronizing created/deleted tasks --- .../todoroo/astrid/common/SyncProvider.java | 12 +++++------ .../sync/ProducteevSyncProvider.java | 20 ++++++++++++++----- .../astrid/rmilk/sync/RTMSyncProvider.java | 3 ++- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/common/SyncProvider.java b/astrid/plugin-src/com/todoroo/astrid/common/SyncProvider.java index 859809b97..11477a6b0 100644 --- a/astrid/plugin-src/com/todoroo/astrid/common/SyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/common/SyncProvider.java @@ -15,8 +15,8 @@ import android.content.Context; import android.widget.Toast; import com.timsu.astrid.R; -import com.todoroo.andlib.data.Property.LongProperty; import com.todoroo.andlib.data.TodorooCursor; +import com.todoroo.andlib.data.Property.LongProperty; import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.ExceptionService; @@ -72,9 +72,11 @@ public abstract class SyncProvider { /** * Create a task on the remote server. * - * @return task to create + * @param task + * task to create + * @return task created on remote server */ - abstract protected void create(TYPE task) throws IOException; + abstract protected TYPE create(TYPE task) throws IOException; /** * Push variables from given task to the remote server. @@ -231,10 +233,6 @@ public abstract class SyncProvider { remote.task.setId(local.task.getId()); data.remoteUpdated.set(remoteIndex, remote); - // if remote is deleted, undelete it, since we just created - if(remote.task.isDeleted()) - remote.task.setValue(Task.DELETION_DATE, 0L); - } else { create(local); } diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java index 909f1a57b..7d7330780 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java @@ -51,6 +51,7 @@ import com.todoroo.astrid.utility.Preferences; @SuppressWarnings("nls") public class ProducteevSyncProvider extends SyncProvider { + private static final long TASK_ID_UNSYNCED = 1L; private ProducteevDataService dataService = null; private ProducteevInvoker invoker = null; private final ProducteevUtilities preferences = ProducteevUtilities.INSTANCE; @@ -299,7 +300,7 @@ public class ProducteevSyncProvider extends SyncProvider 0) invoker.tasksDelete(idTask); - else - create(local); + else { + // if we create, we transfer identifiers to old remote + // in case it is used by caller for other purposes + ProducteevTaskContainer newRemote = create(local); + transferIdentifiers(newRemote, remote); + remote = newRemote; + } } // dashboard if(remote != null && idDashboard != remote.pdvTask.getValue(ProducteevTask.DASHBOARD_ID)) { invoker.tasksSetWorkspace(idTask, idDashboard); remote = pull(local); + } else if(remote == null && idTask == TASK_ID_UNSYNCED) { + // was un-synced, create remote + remote = create(local); } // core properties diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java index b9c38e30d..ce0ff6ec1 100644 --- a/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java @@ -349,7 +349,7 @@ public class RTMSyncProvider extends SyncProvider { // ---------------------------------------------------------------------- @Override - protected void create(RTMTaskContainer task) throws IOException { + protected RTMTaskContainer create(RTMTaskContainer task) throws IOException { String listId = null; if(task.listId > 0) listId = Long.toString(task.listId); @@ -358,6 +358,7 @@ public class RTMSyncProvider extends SyncProvider { RTMTaskContainer newRemoteTask = parseRemoteTask(rtmTask); transferIdentifiers(newRemoteTask, task); push(task, newRemoteTask); + return newRemoteTask; } /**