Update alarms after completion transaction

pull/2906/head
Alex Baker 6 months ago
parent 86ecd3cf81
commit 97a3f074d0

@ -6,13 +6,14 @@
package com.todoroo.astrid.alarms
import org.tasks.LocalBroadcastManager
import org.tasks.data.entity.Alarm
import org.tasks.data.entity.Alarm.Companion.TYPE_SNOOZE
import org.tasks.data.dao.AlarmDao
import org.tasks.data.dao.TaskDao
import org.tasks.data.entity.Alarm
import org.tasks.data.entity.Alarm.Companion.TYPE_SNOOZE
import org.tasks.jobs.AlarmEntry
import org.tasks.jobs.WorkManager
import org.tasks.notifications.NotificationManager
import org.tasks.time.DateTime
import org.tasks.time.DateTimeUtils2.currentTimeMillis
import timber.log.Timber
import javax.inject.Inject
@ -56,7 +57,6 @@ class AlarmService @Inject constructor(
changed = true
}
if (changed) {
workManager.triggerNotifications()
localBroadcastManager.broadcastRefreshList()
}
return changed
@ -81,7 +81,7 @@ class AlarmService @Inject constructor(
val alarmEntries = alarms.mapNotNull {
alarmCalculator.toAlarmEntry(task, it)
}
val (now, later) = alarmEntries.partition { it.time <= currentTimeMillis() }
val (now, later) = alarmEntries.partition { it.time <= DateTime().startOfMinute().plusMinutes(1).millis }
later
.find { it.type == TYPE_SNOOZE }
?.let { future.add(it) }

@ -101,6 +101,8 @@ class TaskDao @Inject constructor(
suspend fun save(task: Task, original: Task?) {
if (taskDao.update(task, original)) {
afterUpdate(task, original)
workManager.triggerNotifications()
workManager.scheduleRefresh()
}
}
@ -122,8 +124,6 @@ class TaskDao @Inject constructor(
if (completionDateModified || deletionDateModified) {
geofenceApi.update(task.id)
}
workManager.triggerNotifications()
workManager.scheduleRefresh()
if (!task.isSuppressRefresh()) {
localBroadcastManager.broadcastRefresh()
}

@ -14,6 +14,7 @@ import org.tasks.LocalBroadcastManager
import org.tasks.data.dao.CaldavDao
import org.tasks.data.db.Database
import org.tasks.data.entity.Task
import org.tasks.jobs.WorkManager
import org.tasks.notifications.NotificationManager
import org.tasks.preferences.Preferences
import org.tasks.time.DateTimeUtils2.currentTimeMillis
@ -29,7 +30,8 @@ class TaskCompleter @Inject internal constructor(
private val localBroadcastManager: LocalBroadcastManager,
private val repeatTaskHelper: RepeatTaskHelper,
private val caldavDao: CaldavDao,
private val gCalHelper: GCalHelper
private val gCalHelper: GCalHelper,
private val workManager: WorkManager,
) {
suspend fun setComplete(taskId: Long) =
taskDao
@ -93,6 +95,8 @@ class TaskCompleter @Inject internal constructor(
}
}
}
workManager.triggerNotifications()
workManager.scheduleRefresh()
if (completed && notificationManager.currentInterruptionFilter == INTERRUPTION_FILTER_ALL) {
preferences
.completionSound

Loading…
Cancel
Save