Never write pushed_at value in MakeChanges

pull/14/head
Sam Bosley 13 years ago
parent 1e9839b4b6
commit 9e64858c8f

@ -1,7 +1,6 @@
package com.todoroo.astrid.actfm.sync; package com.todoroo.astrid.actfm.sync;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -18,7 +17,6 @@ import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.actfm.sync.messages.BriefMe; import com.todoroo.astrid.actfm.sync.messages.BriefMe;
import com.todoroo.astrid.actfm.sync.messages.ChangesHappened; import com.todoroo.astrid.actfm.sync.messages.ChangesHappened;
import com.todoroo.astrid.actfm.sync.messages.ClientToServerMessage; import com.todoroo.astrid.actfm.sync.messages.ClientToServerMessage;
@ -194,18 +192,11 @@ public class ActFmSyncThread {
JSONObject response = actFmInvoker.postSync(payload, token); JSONObject response = actFmInvoker.postSync(payload, token);
// process responses // process responses
JSONArray serverMessagesJson = response.optJSONArray("messages"); JSONArray serverMessagesJson = response.optJSONArray("messages");
String modelPushedAtString = response.optString("time");
long modelPushedAt = 0;
try {
modelPushedAt = DateUtilities.parseIso8601(modelPushedAtString);
} catch (ParseException e) {
Log.e(ERROR_TAG, "Unparseable date " + modelPushedAtString, e);
}
if (serverMessagesJson != null) { if (serverMessagesJson != null) {
for (int i = 0; i < serverMessagesJson.length(); i++) { for (int i = 0; i < serverMessagesJson.length(); i++) {
JSONObject serverMessageJson = serverMessagesJson.optJSONObject(i); JSONObject serverMessageJson = serverMessagesJson.optJSONObject(i);
if (serverMessageJson != null) { if (serverMessageJson != null) {
ServerToClientMessage serverMessage = ServerToClientMessage.instantiateMessage(serverMessageJson, modelPushedAt); ServerToClientMessage serverMessage = ServerToClientMessage.instantiateMessage(serverMessageJson);
if (serverMessage != null) { if (serverMessage != null) {
serverMessage.processMessage(); serverMessage.processMessage();
} else { } else {

@ -12,7 +12,6 @@ import android.util.Log;
import com.todoroo.andlib.data.AbstractModel; import com.todoroo.andlib.data.AbstractModel;
import com.todoroo.andlib.data.Property; import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.Property.LongProperty;
import com.todoroo.andlib.data.Property.StringProperty; import com.todoroo.andlib.data.Property.StringProperty;
import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Criterion;
import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.core.PluginServices;
@ -33,13 +32,11 @@ public class MakeChanges<TYPE extends RemoteModel> extends ServerToClientMessage
private final RemoteModelDao<TYPE> dao; private final RemoteModelDao<TYPE> dao;
private final String table; private final String table;
private final long pushedAt;
public MakeChanges(JSONObject json, RemoteModelDao<TYPE> dao, long pushedAt) { public MakeChanges(JSONObject json, RemoteModelDao<TYPE> dao) {
super(json); super(json);
this.table = json.optString("table"); this.table = json.optString("table");
this.dao = dao; this.dao = dao;
this.pushedAt = pushedAt;
} }
@Override @Override
@ -65,9 +62,6 @@ public class MakeChanges<TYPE extends RemoteModel> extends ServerToClientMessage
uuid = model.getValue(uuidProperty); uuid = model.getValue(uuidProperty);
beforeSaveChanges(changes, model, uuid); beforeSaveChanges(changes, model, uuid);
LongProperty pushedAtProperty = (LongProperty) NameMaps.serverColumnNameToLocalProperty(table, "pushed_at");
if (pushedAtProperty != null && pushedAt > 0)
model.setValue(pushedAtProperty, pushedAt);
if (model.getSetValues() != null && !model.getSetValues().containsKey(uuidProperty.name)) if (model.getSetValues() != null && !model.getSetValues().containsKey(uuidProperty.name))
model.setValue(uuidProperty, uuid); model.setValue(uuidProperty, uuid);

@ -26,10 +26,10 @@ public abstract class ServerToClientMessage {
this.json = json; this.json = json;
} }
public static ServerToClientMessage instantiateMessage(JSONObject json, long pushedAt) { public static ServerToClientMessage instantiateMessage(JSONObject json) {
String type = json.optString("type"); String type = json.optString("type");
if (TYPE_MAKE_CHANGES.equals(type)) if (TYPE_MAKE_CHANGES.equals(type))
return instantiateMakeChanges(json, pushedAt); return instantiateMakeChanges(json);
else if (TYPE_NOW_BRIEFED.equals(type)) else if (TYPE_NOW_BRIEFED.equals(type))
return instantiateNowBriefed(json); return instantiateNowBriefed(json);
else if (TYPE_ACKNOWLEDGE_CHANGE.equals(type)) else if (TYPE_ACKNOWLEDGE_CHANGE.equals(type))
@ -44,16 +44,16 @@ public abstract class ServerToClientMessage {
return null; return null;
} }
private static MakeChanges<?> instantiateMakeChanges(JSONObject json, long pushedAt) { private static MakeChanges<?> instantiateMakeChanges(JSONObject json) {
String table = json.optString("table"); String table = json.optString("table");
if (NameMaps.TABLE_ID_TASKS.equals(table)) if (NameMaps.TABLE_ID_TASKS.equals(table))
return new MakeChanges<Task>(json, PluginServices.getTaskDao(), pushedAt); return new MakeChanges<Task>(json, PluginServices.getTaskDao());
else if (NameMaps.TABLE_ID_TAGS.equals(table)) else if (NameMaps.TABLE_ID_TAGS.equals(table))
return new MakeChanges<TagData>(json, PluginServices.getTagDataDao(), pushedAt); return new MakeChanges<TagData>(json, PluginServices.getTagDataDao());
else if (NameMaps.TABLE_ID_USERS.equals(table)) else if (NameMaps.TABLE_ID_USERS.equals(table))
return new MakeChanges<User>(json, PluginServices.getUserDao(), pushedAt); return new MakeChanges<User>(json, PluginServices.getUserDao());
else if (NameMaps.TABLE_ID_USER_ACTIVITY.equals(table)) else if (NameMaps.TABLE_ID_USER_ACTIVITY.equals(table))
return new MakeChanges<UserActivity>(json, PluginServices.getUserActivityDao(), pushedAt); return new MakeChanges<UserActivity>(json, PluginServices.getUserActivityDao());
else else
return null; return null;
} }

Loading…
Cancel
Save