Cancel notification if new due date is in future

pull/1061/head
Alex Baker 4 years ago
parent cb236bc0e8
commit da256f2293

@ -13,6 +13,7 @@ import org.tasks.LocalBroadcastManager
import org.tasks.data.SubtaskInfo import org.tasks.data.SubtaskInfo
import org.tasks.data.TaskContainer import org.tasks.data.TaskContainer
import org.tasks.data.TaskDao import org.tasks.data.TaskDao
import org.tasks.date.DateTimeUtils.newDateTime
import org.tasks.db.SuspendDbUtils.eachChunk import org.tasks.db.SuspendDbUtils.eachChunk
import org.tasks.jobs.WorkManager import org.tasks.jobs.WorkManager
import org.tasks.location.GeofenceApi import org.tasks.location.GeofenceApi
@ -97,6 +98,9 @@ class TaskDao @Inject constructor(
timerPlugin.stopTimer(task) timerPlugin.stopTimer(task)
} }
} }
if (task.dueDate != original?.dueDate && newDateTime(task.dueDate).isAfterNow) {
notificationManager.cancel(task.id)
}
if (completionDateModified || deletionDateModified) { if (completionDateModified || deletionDateModified) {
geofenceApi.update(task.id) geofenceApi.update(task.id)
} }

@ -244,9 +244,6 @@ class DateTimePicker : BottomSheetDialogFragment() {
if (taskId > 0) { if (taskId > 0) {
lifecycleScope.launch(NonCancellable) { lifecycleScope.launch(NonCancellable) {
val task: Task = taskDao.fetch(taskId)!! val task: Task = taskDao.fetch(taskId)!!
if (newDateTime(dueDate).isAfterNow) {
notificationManager.cancel(task.id)
}
task.setDueDateAdjustingHideUntil(dueDate) task.setDueDateAdjustingHideUntil(dueDate)
taskDao.save(task) taskDao.save(task)
} }

Loading…
Cancel
Save