From 3698244f13568b9d2dd4c7ac736eb1a5bf2cb2c1 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 1 Apr 2013 15:33:09 -0700 Subject: [PATCH] Send current GCM token if one exists and message batch contains a ChangesHappened --- .../com/todoroo/astrid/actfm/sync/ActFmSyncThread.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 909dd9af2..48e456f94 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java @@ -287,10 +287,13 @@ public class ActFmSyncThread { if (!messageBatch.isEmpty() && checkForToken()) { JSONArray payload = new JSONArray(); MultipartEntity entity = new MultipartEntity(); + boolean containsChangesHappened = false; for (int i = 0; i < messageBatch.size(); i++) { ClientToServerMessage message = messageBatch.get(i); JSONObject serialized = message.serializeToJSON(entity); if (serialized != null) { + if (message instanceof ChangesHappened) + containsChangesHappened = true; payload.put(serialized); syncLog("Sending: " + serialized); } else { @@ -311,7 +314,7 @@ public class ActFmSyncThread { JSONArray errors = null; try { - JSONObject response = actFmInvoker.postSync(payload, entity, token); + JSONObject response = actFmInvoker.postSync(payload, entity, containsChangesHappened, token); // process responses String time = response.optString("time"); JSONArray serverMessagesJson = response.optJSONArray("messages");