From 0fcab69e5bf7d4cfd5ff836551d9cd0b68188ddc Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Thu, 17 Feb 2022 09:24:31 -0600 Subject: [PATCH] Fix calendar entry updates --- app/src/main/java/com/todoroo/astrid/dao/TaskDao.kt | 5 +++++ .../main/java/com/todoroo/astrid/service/TaskCompleter.kt | 2 -- 2 files changed, 5 insertions(+), 2 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 25ca6e9ff..0687c4eec 100644 --- a/app/src/main/java/com/todoroo/astrid/dao/TaskDao.kt +++ b/app/src/main/java/com/todoroo/astrid/dao/TaskDao.kt @@ -18,6 +18,7 @@ import org.tasks.data.TaskContainer import org.tasks.data.TaskDao import org.tasks.date.DateTimeUtils.isAfterNow import org.tasks.db.SuspendDbUtils.eachChunk +import org.tasks.jobs.WorkManager import org.tasks.location.GeofenceApi import org.tasks.notifications.NotificationManager import org.tasks.preferences.Preferences @@ -34,6 +35,7 @@ class TaskDao @Inject constructor( private val timerPlugin: TimerPlugin, private val syncAdapters: SyncAdapters, private val alarmService: AlarmService, + private val workManager: WorkManager, ) { suspend fun fetch(id: Long): Task? = taskDao.fetch(id) @@ -112,6 +114,9 @@ class TaskDao @Inject constructor( val deletionDateModified = task.deletionDate != original?.deletionDate ?: 0 val justCompleted = completionDateModified && task.isCompleted val justDeleted = deletionDateModified && task.isDeleted + if (task.calendarURI?.isNotBlank() == true) { + workManager.updateCalendar(task) + } coroutineScope { launch(Dispatchers.Default) { if (justCompleted || justDeleted) { diff --git a/app/src/main/java/com/todoroo/astrid/service/TaskCompleter.kt b/app/src/main/java/com/todoroo/astrid/service/TaskCompleter.kt index 199e7fa31..7cec2381d 100644 --- a/app/src/main/java/com/todoroo/astrid/service/TaskCompleter.kt +++ b/app/src/main/java/com/todoroo/astrid/service/TaskCompleter.kt @@ -69,8 +69,6 @@ class TaskCompleter @Inject internal constructor( tasks.forEach { if (completed && it.isRecurring) { workManager.scheduleRepeat(it) - } else if (!it.calendarURI.isNullOrBlank()) { - workManager.updateCalendar(it) } } if (completed && notificationManager.currentInterruptionFilter == INTERRUPTION_FILTER_ALL) {