From e98e12537c56e78a55c3b1044c4cda99cf6bdaf5 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Fri, 12 Apr 2013 16:20:48 -0700 Subject: [PATCH] UserMigrated should update user ids for both the old and new ids --- .../actfm/sync/messages/ConvertSelfUserIdsToZero.java | 8 ++++++-- .../todoroo/astrid/actfm/sync/messages/UserMigrated.java | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ConvertSelfUserIdsToZero.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ConvertSelfUserIdsToZero.java index 4825507cd..5921b024d 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ConvertSelfUserIdsToZero.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ConvertSelfUserIdsToZero.java @@ -40,8 +40,7 @@ public class ConvertSelfUserIdsToZero { DependencyInjectionService.getInstance().inject(this); } - public synchronized void execute() { - String selfId = ActFmPreferenceService.userId(); + public synchronized void execute(String selfId) { if (RemoteModel.isValidUuid(selfId)) { updateDatabase(taskDao, new Task(), Task.CREATOR_ID, selfId); updateDatabase(taskDao, new Task(), Task.USER_ID, selfId); @@ -52,6 +51,11 @@ public class ConvertSelfUserIdsToZero { } } + public synchronized void execute() { + String selfId = ActFmPreferenceService.userId(); + execute(selfId); + } + private void updateDatabase(DatabaseDao dao, T instance, StringProperty property, String selfId) { instance.setValue(property, Task.USER_ID_SELF); instance.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true); diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/UserMigrated.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/UserMigrated.java index 0e1425a05..15c94394e 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/UserMigrated.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/UserMigrated.java @@ -14,11 +14,16 @@ public class UserMigrated extends ServerToClientMessage { @Override public void processMessage(String serverTime) { + String oldUuid = json.optString("prev_user_id"); //$NON-NLS-1$ String newUuid = json.optString("new_user_id"); //$NON-NLS-1$ if (RemoteModel.isValidUuid(newUuid)) { Preferences.setString(ActFmPreferenceService.PREF_USER_ID, newUuid); new ConvertSelfUserIdsToZero().execute(); } + + if (RemoteModel.isValidUuid(oldUuid)) { + new ConvertSelfUserIdsToZero().execute(oldUuid); + } } }