Snooze notifications, morning summary, ICS import, data folder sync
- Windows toast notifications with snooze (10 min / 1 h / tomorrow) and done buttons; balloon fallback; works when Windows starts the app - Recurring entries snooze via SnoozedUntil without moving their date; lead reminders keep the real date - Morning summary once a day from a chosen hour (pure DailySummary) - iCalendar import incl. Google birthday calendar, folded lines, UTC, alarms, own export round trip, duplicates skipped by UID, undo - Data folder selectable (location.json pointer), file watcher reloads changes from another PC (own writes ignored) - Themed date picker calendar, WPF tray menu, arrow/Home/End/Space keys - 90 tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
35
Core/DailySummary.cs
Normal file
35
Core/DailySummary.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ReminderOrganizer.Models;
|
||||
|
||||
namespace ReminderOrganizer.Core
|
||||
{
|
||||
/// <summary>Content of the morning summary. Null when there is nothing worth showing.</summary>
|
||||
public sealed record DailySummaryData(
|
||||
IReadOnlyList<ReminderTask> Today,
|
||||
IReadOnlyList<ReminderTask> Overdue,
|
||||
IReadOnlyList<ReminderTask> AnniversariesSoon);
|
||||
|
||||
public static class DailySummary
|
||||
{
|
||||
/// <summary>Days ahead in which anniversaries are announced (tomorrow … in 3 days).</summary>
|
||||
public const int AnniversaryDays = 3;
|
||||
|
||||
public static DailySummaryData? Build(IEnumerable<ReminderTask> tasks, DateTime now)
|
||||
{
|
||||
var open = tasks.Where(t => !t.IsNotified).ToList();
|
||||
var today = open.Where(t => t.ReminderDate.Date == now.Date).OrderBy(t => t.ReminderDate).ToList();
|
||||
var overdue = open.Where(t => !t.IsRecurring && t.ReminderDate.Date < now.Date).OrderBy(t => t.ReminderDate).ToList();
|
||||
var soon = open.Where(t => t.IsAnniversary)
|
||||
.Where(t => (t.ReminderDate.Date - now.Date).Days is > 0 and <= AnniversaryDays)
|
||||
.OrderBy(t => t.ReminderDate).ToList();
|
||||
return today.Count + overdue.Count + soon.Count == 0 ? null : new DailySummaryData(today, overdue, soon);
|
||||
}
|
||||
|
||||
/// <summary>Should the summary be shown now? Once per day, from <paramref name="hour"/> on.</summary>
|
||||
public static bool IsDue(DateTime now, int hour, DateTime? lastShown) =>
|
||||
now.Hour >= hour && (lastShown == null || lastShown.Value.Date < now.Date);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user