Merge pull request #1828 from Hafizzle/Hafiz/reminder-current-time-fix

Reminder current time fix
This commit is contained in:
Phillip Thelen 2022-08-11 10:43:02 +02:00 committed by GitHub
commit d4f466c9ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -82,9 +82,16 @@ class TaskAlarmManager(
return remindersItem
}
/**
* If reminderItem time is before now, a new reminder will not be created until the reminder passes.
* The exception to this is if the task & reminder was newly created for the same time,
* in which the alarm will be created -
* which is indicated by first nextDue being null (As the alarm is created before the API returns nextDue times)
*/
private fun setAlarmForRemindersItem(reminderItemTask: Task, remindersItem: RemindersItem?) {
val now = ZonedDateTime.now().withZoneSameLocal(ZoneId.systemDefault())?.toInstant()
if (remindersItem == null || remindersItem.getLocalZonedDateTimeInstant()?.isBefore(now) == true) {
if (remindersItem == null || (remindersItem.getLocalZonedDateTimeInstant()?.isBefore(now) == true && reminderItemTask.nextDue?.first() != null)) {
return
}