From b9a768a47027785a578fee63ae6909ca6690819f Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 18 Mar 2013 15:57:05 -0700 Subject: [PATCH] Fixed several cases where logging out would not clear table pushed_at values --- .../com/todoroo/astrid/actfm/ActFmLoginActivity.java | 11 +++-------- .../todoroo/astrid/actfm/sync/ActFmSyncThread.java | 7 +++++++ .../astrid/actfm/sync/ActFmSyncV2Provider.java | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java index 474b3caff..c65a5ff09 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java @@ -70,6 +70,7 @@ import com.todoroo.astrid.actfm.sync.ActFmInvoker; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.todoroo.astrid.actfm.sync.ActFmServiceException; import com.todoroo.astrid.actfm.sync.ActFmSyncMonitor; +import com.todoroo.astrid.actfm.sync.ActFmSyncThread; import com.todoroo.astrid.actfm.sync.messages.ConstructOutstandingTableFromMasterTable; import com.todoroo.astrid.actfm.sync.messages.ConstructTaskOutstandingTableFromMasterTable; import com.todoroo.astrid.actfm.sync.messages.NameMaps; @@ -650,6 +651,7 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { + ActFmSyncThread.clearTablePushedAtValues(); deleteDatabase(database.getName()); finishSignIn(result, token, true); } @@ -708,7 +710,7 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener // Generate new uuids for all tasks/tags/user activity/task list metadata and update links generateNewUuids(); - clearTablePushedAtValues(); + ActFmSyncThread.clearTablePushedAtValues(); constructOutstandingTables(); } @@ -816,13 +818,6 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener } - private void clearTablePushedAtValues() { - String[] pushedAtPrefs = new String[] { NameMaps.PUSHED_AT_TASKS, NameMaps.PUSHED_AT_TAGS, - NameMaps.PUSHED_AT_ACTIVITY, NameMaps.PUSHED_AT_USERS, NameMaps.PUSHED_AT_TASK_LIST_METADATA }; - for (String key : pushedAtPrefs) - Preferences.clear(key); - } - private void mapUuids(RemoteModelDao dao, HashMap map) { TodorooCursor items = dao.query(Query.select(RemoteModel.UUID_PROPERTY)); try { 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 19a065aa8..aacd1f5d0 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java @@ -195,6 +195,13 @@ public class ActFmSyncThread { } }; + public static void clearTablePushedAtValues() { + String[] pushedAtPrefs = new String[] { NameMaps.PUSHED_AT_TASKS, NameMaps.PUSHED_AT_TAGS, + NameMaps.PUSHED_AT_ACTIVITY, NameMaps.PUSHED_AT_USERS, NameMaps.PUSHED_AT_TASK_LIST_METADATA }; + for (String key : pushedAtPrefs) + Preferences.clear(key); + } + public synchronized void enqueueMessage(ClientToServerMessage message, Runnable callback) { if (!RemoteModelDao.getOutstandingEntryFlag(RemoteModelDao.OUTSTANDING_ENTRY_FLAG_ENQUEUE_MESSAGES)) return; 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 275ec7171..4dfac69d3 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java @@ -71,6 +71,7 @@ public class ActFmSyncV2Provider extends SyncV2Provider { @Override public void onClick(DialogInterface dialog, int which) { Preferences.clear(ActFmPreferenceService.PREF_USER_ID); // As though no one has ever logged in + ActFmSyncThread.clearTablePushedAtValues(); activity.deleteDatabase(database.getName()); RemoteModelDao.setOutstandingEntryFlags(RemoteModelDao.OUTSTANDING_FLAG_UNINITIALIZED); System.exit(0);