From 1f2eb576020b14f3927f8d7c372d470a3a9e965b Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 1 Dec 2022 18:41:24 +0100 Subject: [PATCH] fix(reminders): make sure an overdue reminder is sent when there is only one overdue task --- pkg/models/task_overdue_reminder.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/models/task_overdue_reminder.go b/pkg/models/task_overdue_reminder.go index 72549e0b780..e68fb92f281 100644 --- a/pkg/models/task_overdue_reminder.go +++ b/pkg/models/task_overdue_reminder.go @@ -140,9 +140,13 @@ func RegisterOverdueReminderCron() { } if len(ut.tasks) == 1 { - n = &UndoneTaskOverdueNotification{ - User: ut.user, - Task: ut.tasks[0], + // We know there's only one entry in the map so this is actually O(1) and we can use it to get the + // first entry without knowing the key of it. + for _, t := range ut.tasks { + n = &UndoneTaskOverdueNotification{ + User: ut.user, + Task: t, + } } }