Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

Reminders: Completed, as Reminders' own smart list

Yashwanth Kamireddi80824154a2d3
diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjs
index 58e9ba2..9191111 100644
--- a/.uiverify/stub.mjs
+++ b/.uiverify/stub.mjs
@@ -255,7 +255,7 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
case "event_save": (window.__eventSaves ??= []).push(args.draft); return "E-new";
case "event_delete": (window.__eventDeletes ??= []).push(args); return null;
case "calendar_sync": return { calendars: calendars.length, events: events.length };
- case "reminder_counts": return { today: 4, scheduled: 7, flagged: 2, all: 12, lists: [["L1", 5], ["L2", 3], ["lists", 4]] };
+ case "reminder_counts": return { today: 4, scheduled: 7, flagged: 2, all: 12, completed: 3, lists: [["L1", 5], ["L2", 3], ["lists", 4]] };
case "reminder_lists": return !remindersFixture ? [] : reminderLists;
case "reminders_in": {
if (!remindersFixture || remindersFixture === "lists") return [];
@@ -297,6 +297,9 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
const last = (window.__ending ?? []).includes(args.guid);
if (r && last && args.done) { r.completedAt = Math.floor(Date.now() / 1000); window.__ending = window.__ending.filter((g) => g !== args.guid); }
else if (r && r.recurFrequency !== null && r.recurFrequency !== undefined && args.done) r.dueAt += 86400 * (r.recurInterval ?? 1);
+ // Unticked, a fixture reminder is open again in the library.
+ const own = reminderItems.find((x) => x.guid === args.guid);
+ if (own && !args.done) own.completedAt = null;
}
return null;
case "reminder_set_repeat": {
@@ -351,7 +354,13 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
case "reminder_list_create": case "reminder_list_rename": case "reminder_list_delete":
return null;
// A suite's own reminders in the smart lists (`window.__smartExtra`).
- case "reminders_smart": return !remindersFixture || remindersFixture === "lists" ? [] : [...reminderItems, ...(window.__smartExtra ?? [])].filter(r => !r.completedAt);
+ case "reminders_smart": {
+ if (!remindersFixture || remindersFixture === "lists") return [];
+ const every = [...reminderItems, ...(window.__smartExtra ?? [])];
+ // Completed: those ticked off, the latest first (reminders.rs reminders_smart).
+ if (args?.kind === "completed") return every.filter((r) => r.completedAt).sort((a, b) => b.completedAt - a.completedAt);
+ return every.filter((r) => !r.completedAt);
+ }
// Reminders' details (reminders_cmds.rs): tags, a link, early alerts, custom smart lists
// and sections. A test sets __tagMap / __details / __smartLists / __sections to change them.
case "reminder_sections": return (window.__sections ?? []).filter((s) => s.listGuid === args.listGuid);
diff --git a/crates/quince-core/src/reminders.rs b/crates/quince-core/src/reminders.rs
index 8f401ed..f260e64 100644
--- a/crates/quince-core/src/reminders.rs
+++ b/crates/quince-core/src/reminders.rs
@@ -190,10 +190,15 @@ pub struct ReminderCounts {
pub scheduled: usize,
pub flagged: usize,
pub all: usize,
+ /// Every reminder ticked off, in every list shown.
+ pub completed: usize,
/// Outstanding reminders per list, keyed by list guid.
pub lists: Vec<(String, usize)>,
}
+/// What the Completed list holds, for its tile's count and for opening it alike.
+const COMPLETED: &str = "r.completed_at IS NOT NULL";
+
/// Apple's built-in views over every list.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
@@ -202,6 +207,9 @@ pub enum SmartList {
Scheduled,
Flagged,
All,
+ /// Every reminder ticked off, the most recently completed first, as Reminders' own
+ /// Completed list shows them.
+ Completed,
}
impl Reminder {
@@ -709,6 +717,7 @@ impl Library {
scheduled: one("r.completed_at IS NULL AND r.due_at IS NOT NULL", &[])?,
flagged: one("r.completed_at IS NULL AND r.flagged = 1", &[])?,
all: one("r.completed_at IS NULL", &[])?,
+ completed: one(COMPLETED, &[])?,
lists,
})
}
@@ -722,6 +731,13 @@ impl Library {
SmartList::Scheduled => ("r.completed_at IS NULL AND r.due_at IS NOT NULL", vec![]),
SmartList::Flagged => ("r.completed_at IS NULL AND r.flagged = 1", vec![]),
SmartList::All => ("r.completed_at IS NULL", vec![]),
+ SmartList::Completed => (COMPLETED, vec![]),
+ };
+ // Completed reminders come latest first; the rest by when they are due.
+ let order = if kind == SmartList::Completed {
+ "r.completed_at DESC, r.title"
+ } else {
+ "r.due_at IS NULL, r.due_at, r.priority DESC, r.title"
};
let sql = format!(
"SELECT r.guid, r.list_guid, r.title, r.notes, r.due_at, r.completed_at,
@@ -730,7 +746,7 @@ impl Library {
FROM reminders r
JOIN reminder_lists l ON l.guid = r.list_guid
WHERE l.enabled = 1 AND {clause}
- ORDER BY r.due_at IS NULL, r.due_at, r.priority DESC, r.title
+ ORDER BY {order}
LIMIT {MOST_AT_ONCE}"
);
let mut stmt = self.conn.prepare(&sql)?;
@@ -1500,6 +1516,7 @@ mod smart_tests {
SmartList::Scheduled,
SmartList::Flagged,
SmartList::All,
+ SmartList::Completed,
] {
assert!(lib.reminders_smart(kind, DAY_END).unwrap().is_empty());
}
@@ -1585,6 +1602,7 @@ mod count_tests {
(SmartList::Scheduled, counts.scheduled),
(SmartList::Flagged, counts.flagged),
(SmartList::All, counts.all),
+ (SmartList::Completed, counts.completed),
] {
assert_eq!(
lib.reminders_smart(kind, now).unwrap().len(),
@@ -1594,6 +1612,26 @@ mod count_tests {
}
assert_eq!(counts.today, 1, "overdue counts as today");
assert_eq!(counts.all, 3, "completed does not count");
+ assert_eq!(counts.completed, 1, "Completed holds the one ticked off");
+ }
+
+ /// Completed shows the reminders ticked off, the latest first.
+ #[test]
+ fn completed_lists_the_latest_first() {
+ let mut lib = library();
+ let mut early = reminder("early", "L1", None, true, false);
+ early.completed_at = Some(100);
+ let mut late = reminder("late", "L1", None, true, false);
+ late.completed_at = Some(900);
+ lib.put_reminders(&[early, late, reminder("open", "L1", None, false, false)])
+ .unwrap();
+ let shown: Vec<String> = lib
+ .reminders_smart(SmartList::Completed, 0)
+ .unwrap()
+ .into_iter()
+ .map(|r| r.guid)
+ .collect();
+ assert_eq!(shown, vec!["late", "early"]);
}
/// A list nobody has switched on contributes to nothing.
diff --git a/src/components/Glyph.tsx b/src/components/Glyph.tsx
index 0f96cc4..916f20c 100644
--- a/src/components/Glyph.tsx
+++ b/src/components/Glyph.tsx
@@ -1,6 +1,7 @@
import {
BookOpen,
Calendar,
+ Check,
CalendarDays,
ChevronRight,
Dumbbell,
@@ -23,6 +24,7 @@ export type GlyphName =
| "scheduled"
| "all"
| "flagged"
+ | "completed"
| "list"
| "bullets"
| "fitness"
@@ -47,6 +49,7 @@ const ICONS: Record<GlyphName, { icon: LucideIcon; filled?: boolean }> = {
scheduled: { icon: CalendarDays },
all: { icon: Inbox },
flagged: { icon: Flag, filled: true },
+ completed: { icon: Check },
list: { icon: List },
bullets: { icon: List },
fitness: { icon: Dumbbell },
diff --git a/src/lib/ipc.ts b/src/lib/ipc.ts
index 0a3de63..e13f71e 100644
--- a/src/lib/ipc.ts
+++ b/src/lib/ipc.ts
@@ -543,7 +543,7 @@ export type ReminderSection = {
createdAt: number | null;
};
-export type SmartList = "today" | "scheduled" | "flagged" | "all";
+export type SmartList = "today" | "scheduled" | "flagged" | "all" | "completed";
/** What every entry in the Reminders sidebar is holding. */
export type ReminderCounts = {
@@ -551,6 +551,8 @@ export type ReminderCounts = {
scheduled: number;
flagged: number;
all: number;
+ /** Every reminder ticked off. */
+ completed: number;
/** [list guid, outstanding count] */
lists: [string, number][];
};
diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsx
index a225334..adb7df9 100644
--- a/src/screens/RemindersView.tsx
+++ b/src/screens/RemindersView.tsx
@@ -54,6 +54,7 @@ const SMART: { kind: SmartList; title: string; glyph: GlyphName; colour: string
{ kind: "scheduled", title: "Scheduled", glyph: "scheduled", colour: "var(--sys-red)" },
{ kind: "all", title: "All", glyph: "all", colour: "var(--sys-gray)" },
{ kind: "flagged", title: "Flagged", glyph: "flagged", colour: "var(--sys-orange)" },
+ { kind: "completed", title: "Completed", glyph: "completed", colour: "var(--sys-gray)" },
];
/** A list's own colour, or Apple's blue for one that has none. */
@@ -752,7 +753,8 @@ export function RemindersView() {
setItems(patch(r.guid, { completedAt: wasOpen ? Math.floor(Date.now() / 1000) : null }));
// Only where completed reminders are hidden, and never for a repeating one, which rolls on.
// Its last time before End Repeat is a completion too, as on the phone.
- if (wasOpen && !showDone && !repeating) depart(r.guid);
+ // In Completed, a reminder unticked is no longer completed, and leaves it the same way.
+ if ((wasOpen && !showDone && !repeating) || (!wasOpen && smartKind === "completed")) depart(r.guid);
else stay(r.guid);
const before = ticks.current.get(r.guid) ?? Promise.resolve();
const next = before.then(() => send(r, wasOpen));
@@ -1388,7 +1390,8 @@ export function RemindersView() {
!inList &&
!gathered &&
smartKind !== "all" &&
- smartKind !== "flagged";
+ smartKind !== "flagged" &&
+ smartKind !== "completed";
const sections = useMemo(() => {
if (searching) {
@@ -1534,7 +1537,8 @@ export function RemindersView() {
return out;
}
- // All and Flagged gather from everywhere, so the list each came from is the grouping.
+ // All, Flagged and Completed gather from everywhere, so the list each came from is the
+ // grouping.
const byList = new Map<string, typeof threaded>();
for (const row of threaded) {
const bucket = byList.get(row.reminder.listGuid);
@@ -1677,7 +1681,8 @@ export function RemindersView() {
);
/** Where a reminder typed at the foot of the view is filed, when that is a choice. */
- const canAdd = !gathered || (selection.type === "tag" && REMINDER_DETAIL_WRITES);
+ // Completed has nothing to add to, as on the Mac: a reminder begins open.
+ const canAdd = (!gathered || (selection.type === "tag" && REMINDER_DETAIL_WRITES)) && smartKind !== "completed";
const addRow = targetListGuid && !searching && canAdd && (
<form className="rx-add" onSubmit={add}>
<span className="rx-tick ghost" aria-hidden="true">
@@ -1890,7 +1895,13 @@ export function RemindersView() {
<span>Lists</span>
</button>
<header className="pane-head rx-head">
- <PaneTitle count={`${outstanding} ${outstanding === 1 ? "reminder" : "reminders"}`}>
+ <PaneTitle
+ count={
+ smartKind === "completed" && !searching
+ ? `${items.length - outstanding} completed`
+ : `${outstanding} ${outstanding === 1 ? "reminder" : "reminders"}`
+ }
+ >
{searching ? `Results for “${query.trim()}”` : heading}
</PaneTitle>
{inList && (
@@ -2036,7 +2047,9 @@ export function RemindersView() {
? showDone
? "Nothing in this list yet."
: "All done here."
- : "No Reminders"}
+ : smartKind === "completed"
+ ? "No Completed Reminders"
+ : "No Reminders"}
</EmptyState>
)}
</section>