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: in Today, a subtask stays under its reminder

Yashwanth Kamireddicb44c8c270f1
diff --git a/.uiverify/reminders-today-allday.mjs b/.uiverify/reminders-today-allday.mjs
index 51eb7aa..2030c7c 100644
--- a/.uiverify/reminders-today-allday.mjs
+++ b/.uiverify/reminders-today-allday.mjs
@@ -12,8 +12,14 @@ await ctx.addInitScript(() => {
const d = new Date();
// Today, as Apple keeps a day: its midnight in UTC.
const day = Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) / 1000;
+ const at = (h) => Math.floor(new Date(d.getFullYear(), d.getMonth(), d.getDate(), h).getTime() / 1000);
window.__smartExtra = [{ guid: "allday1", listGuid: "l1", title: "Renew the parking permit", notes: null, dueAt: day, allDay: true,
- completedAt: null, priority: 0, flagged: false, parentGuid: null, etag: null }];
+ completedAt: null, priority: 0, flagged: false, parentGuid: null, etag: null },
+ // A morning reminder with a subtask due in the afternoon: the subtask stays under it.
+ { guid: "par", listGuid: "l1", title: "Get ready for the trip", notes: null, dueAt: at(10), allDay: false,
+ completedAt: null, priority: 0, flagged: false, parentGuid: null, etag: null },
+ { guid: "kid", listGuid: "l1", title: "Charge the camera", notes: null, dueAt: at(15), allDay: false,
+ completedAt: null, priority: 0, flagged: false, parentGuid: "par", etag: null }];
});
await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, remindersFixture: true });
const page = await ctx.newPage();
@@ -34,6 +40,10 @@ const layout = await page.evaluate(() => {
const at = layout.find(([, t]) => t.startsWith("Renew the parking permit"));
ok(at && at[0] === null, `the day's reminder sits above the times of day ${JSON.stringify(at)} ${JSON.stringify(layout.map(([h]) => h))}`);
+const parent = layout.findIndex(([, t]) => t.startsWith("Get ready for the trip"));
+const kid = layout.findIndex(([, t]) => t.startsWith("Charge the camera"));
+ok(parent >= 0 && kid === parent + 1 && layout[kid][0] === layout[parent][0], `a subtask stays under its reminder, in its part of the day ${JSON.stringify([layout[parent], layout[kid]])}`);
+
// One added in Today is the same: due today, no time.
const field = page.locator(".rx-add input").first();
if (await field.count()) {
diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsx
index 1aaa972..b4635be 100644
--- a/src/screens/RemindersView.tsx
+++ b/src/screens/RemindersView.tsx
@@ -1430,23 +1430,37 @@ export function RemindersView() {
{ key: "afternoon", heading: "Afternoon", rows: [] },
{ key: "tonight", heading: "Tonight", rows: [] },
];
+ // A subtask goes where its reminder went, directly under it: filed by its own time, it was
+ // drawn nested under whatever reminder ended another part of the day.
+ let parentBucket = 0;
for (const row of threaded) {
+ if (row.depth > 0) {
+ buckets[parentBucket].rows.push(row);
+ continue;
+ }
const due = row.reminder.dueAt;
// Anything overdue, or with no time at all, sits above the buckets — which is where
// Apple puts it. A day's reminder has no time either: read as its midnight, it went
// under Morning, with every one added here.
if (due === null || row.reminder.allDay || daysApart(now, new Date(due * 1000)) < 0) {
- buckets[0].rows.push(row);
- continue;
+ parentBucket = 0;
+ } else {
+ const hour = new Date(due * 1000).getHours();
+ parentBucket = hour < 12 ? 1 : hour < 17 ? 2 : 3;
}
- const hour = new Date(due * 1000).getHours();
- buckets[hour < 12 ? 1 : hour < 17 ? 2 : 3].rows.push(row);
+ buckets[parentBucket].rows.push(row);
}
// Each part of the day in time order, as Today reads; the list's own order put 9:30
// above 8:30. A subtask keeps its place under its parent.
+ // Its subtasks move with it.
for (const b of buckets.slice(1)) {
- if (b.rows.some((r) => r.depth > 0)) continue;
- b.rows.sort((x, y) => (x.reminder.dueAt ?? 0) - (y.reminder.dueAt ?? 0));
+ const units: (typeof threaded)[] = [];
+ for (const r of b.rows) {
+ if (r.depth > 0 && units.length) units[units.length - 1].push(r);
+ else units.push([r]);
+ }
+ units.sort((x, y) => (x[0].reminder.dueAt ?? 0) - (y[0].reminder.dueAt ?? 0));
+ b.rows = units.flat();
}
return buckets
.filter((b) => b.rows.length > 0)