Don't schedule reminder for completed tasks

This commit is contained in:
Naveen 2023-10-05 21:53:57 +05:30
parent a67c1c79db
commit 908e3853d3
No known key found for this signature in database
GPG key ID: 0E155DAD31671DA3

View file

@ -117,9 +117,15 @@ fun Context.scheduleNextEventReminder(event: Event, showToasts: Boolean) {
val now = getNowSeconds() val now = getNowSeconds()
val reminderSeconds = validReminders.reversed().map { it.minutes * 60 } val reminderSeconds = validReminders.reversed().map { it.minutes * 60 }
val isTask = event.isTask()
eventsHelper.getEvents(now, now + YEAR, event.id!!, false) { events -> eventsHelper.getEvents(now, now + YEAR, event.id!!, false) { events ->
if (events.isNotEmpty()) { if (events.isNotEmpty()) {
for (curEvent in events) { for (curEvent in events) {
if (isTask && curEvent.isTaskCompleted()) {
// skip scheduling reminders for completed tasks
continue
}
for (curReminder in reminderSeconds) { for (curReminder in reminderSeconds) {
if (curEvent.getEventStartTS() - curReminder > now) { if (curEvent.getEventStartTS() - curReminder > now) {
scheduleEventIn((curEvent.getEventStartTS() - curReminder) * 1000L, curEvent, showToasts) scheduleEventIn((curEvent.getEventStartTS() - curReminder) * 1000L, curEvent, showToasts)