From da256f2293a1520ab3488024a9c07496c8903d40 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Fri, 31 Jul 2020 08:40:15 -0500 Subject: [PATCH] Cancel notification if new due date is in future --- app/src/main/java/com/todoroo/astrid/dao/TaskDao.kt | 4 ++++ app/src/main/java/org/tasks/dialogs/DateTimePicker.kt | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/todoroo/astrid/dao/TaskDao.kt b/app/src/main/java/com/todoroo/astrid/dao/TaskDao.kt index ac25e20d9..fe26b8201 100644 --- a/app/src/main/java/com/todoroo/astrid/dao/TaskDao.kt +++ b/app/src/main/java/com/todoroo/astrid/dao/TaskDao.kt @@ -13,6 +13,7 @@ import org.tasks.LocalBroadcastManager import org.tasks.data.SubtaskInfo import org.tasks.data.TaskContainer import org.tasks.data.TaskDao +import org.tasks.date.DateTimeUtils.newDateTime import org.tasks.db.SuspendDbUtils.eachChunk import org.tasks.jobs.WorkManager import org.tasks.location.GeofenceApi @@ -97,6 +98,9 @@ class TaskDao @Inject constructor( timerPlugin.stopTimer(task) } } + if (task.dueDate != original?.dueDate && newDateTime(task.dueDate).isAfterNow) { + notificationManager.cancel(task.id) + } if (completionDateModified || deletionDateModified) { geofenceApi.update(task.id) } diff --git a/app/src/main/java/org/tasks/dialogs/DateTimePicker.kt b/app/src/main/java/org/tasks/dialogs/DateTimePicker.kt index a7b71e770..3af5cf638 100644 --- a/app/src/main/java/org/tasks/dialogs/DateTimePicker.kt +++ b/app/src/main/java/org/tasks/dialogs/DateTimePicker.kt @@ -244,9 +244,6 @@ class DateTimePicker : BottomSheetDialogFragment() { if (taskId > 0) { lifecycleScope.launch(NonCancellable) { val task: Task = taskDao.fetch(taskId)!! - if (newDateTime(dueDate).isAfterNow) { - notificationManager.cancel(task.id) - } task.setDueDateAdjustingHideUntil(dueDate) taskDao.save(task) }