From 74eb59a36e46c71d2e7afce998abb27f7abd45e7 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Wed, 30 Oct 2019 18:13:23 -0500 Subject: [PATCH] Don't delete recurring tasks completed remotely --- .../tasks/gtasks/GoogleTaskSynchronizer.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/tasks/gtasks/GoogleTaskSynchronizer.java b/app/src/main/java/org/tasks/gtasks/GoogleTaskSynchronizer.java index 7a4e95b76..f04f9b2f3 100644 --- a/app/src/main/java/org/tasks/gtasks/GoogleTaskSynchronizer.java +++ b/app/src/main/java/org/tasks/gtasks/GoogleTaskSynchronizer.java @@ -445,12 +445,31 @@ public class GoogleTaskSynchronizer { } Boolean isDeleted = gtask.getDeleted(); Boolean isHidden = gtask.getHidden(); - if ((isDeleted != null && isDeleted) || (isHidden != null && isHidden)) { + if (isDeleted != null && isDeleted) { if (task != null) { taskDeleter.delete(task); } continue; + } else if (isHidden != null && isHidden) { + if (task == null) { + continue; + } + if (task.isRecurring()) { + googleTask.setRemoteId(""); + } else { + taskDeleter.delete(task); + continue; + } + } else { + googleTask.setRemoteOrder(Long.parseLong(gtask.getPosition())); + googleTask.setRemoteParent(gtask.getParent()); + googleTask.setParent( + Strings.isNullOrEmpty(gtask.getParent()) + ? 0 + : googleTaskDao.getTask(gtask.getParent())); + googleTask.setRemoteId(gtask.getId()); } + if (task == null) { task = taskCreator.createWithValues(""); } @@ -462,13 +481,7 @@ public class GoogleTaskSynchronizer { long dueDate = GtasksApiUtilities.gtasksDueTimeToUnixTime(gtask.getDue()); mergeDates(Task.createDueDate(Task.URGENCY_SPECIFIC_DAY, dueDate), task); task.setNotes(gtask.getNotes()); - googleTask.setRemoteId(gtask.getId()); googleTask.setListId(listId); - - googleTask.setRemoteOrder(Long.parseLong(gtask.getPosition())); - googleTask.setRemoteParent(gtask.getParent()); - googleTask.setParent( - Strings.isNullOrEmpty(gtask.getParent()) ? 0 : googleTaskDao.getTask(gtask.getParent())); googleTask.setLastSync(DateUtilities.now() + 1000L); write(task, googleTask); }