Force caldav sync on location change

pull/935/head
Alex Baker 5 years ago
parent b893094198
commit c55c1e6333

@ -8,4 +8,5 @@ package com.todoroo.astrid.data;
public class SyncFlags {
public static final String SUPPRESS_SYNC = "suppress_sync";
public static final String FORCE_CALDAV_SYNC = "force_caldav_sync";
}

@ -60,11 +60,13 @@ public class AfterSaveWork extends InjectingWorker {
static Data getInputData(Task current, Task original) {
boolean suppress = current.checkTransitory(SyncFlags.SUPPRESS_SYNC);
boolean forceCaldav = current.checkTransitory(SyncFlags.FORCE_CALDAV_SYNC);
Builder builder =
new Builder()
.putLong(EXTRA_ID, current.getId())
.putBoolean(EXTRA_PUSH_GTASKS, !suppress && !current.googleTaskUpToDate(original))
.putBoolean(EXTRA_PUSH_CALDAV, !suppress && !current.caldavUpToDate(original))
.putBoolean(
EXTRA_PUSH_CALDAV, !suppress && (!current.caldavUpToDate(original) || forceCaldav))
.putBoolean(EXTRA_SUPPRESS_REFRESH, current.checkTransitory(TRANS_SUPPRESS_REFRESH));
if (original != null) {
builder

@ -2,6 +2,7 @@ package org.tasks.ui;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Lists.transform;
import static com.todoroo.astrid.data.SyncFlags.FORCE_CALDAV_SYNC;
import static org.tasks.PermissionUtil.verifyPermissions;
import static org.tasks.dialogs.GeofenceDialog.newGeofenceDialog;
import static org.tasks.location.LocationPickerActivity.EXTRA_PLACE;
@ -250,6 +251,10 @@ public class LocationControlSet extends TaskEditControlFragment {
@Override
public void apply(Task task) {
if ((original == null || location == null || !original.place.equals(location.place))) {
task.putTransitory(FORCE_CALDAV_SYNC, true);
}
if (original != null) {
geofenceApi.cancel(original);
locationDao.delete(original.geofence);

Loading…
Cancel
Save