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 Scheduled, a subtask stays under its reminder

Yashwanth Kamireddif63ae864ebc5
diff --git a/.uiverify/reminders-scheduled-subtask.mjs b/.uiverify/reminders-scheduled-subtask.mjs
new file mode 100644
index 0000000..dbd69c6
--- /dev/null
+++ b/.uiverify/reminders-scheduled-subtask.mjs
@@ -0,0 +1,36 @@
+// Scheduled, by day: a subtask due another day than its reminder stays directly under it,
+// rather than being drawn nested under whatever ends that other day.
+import { engine } from "./engine.mjs";
+import { SERVICES, installStub, openScreen } from "./stub.mjs";
+const BASE = process.env.BASE ?? "http://localhost:4202";
+const b = await engine.launch();
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+const ctx = await b.newContext({ viewport: { width: 1200, height: 800 } });
+await ctx.addInitScript(() => {
+ const d = new Date();
+ const at = (days, h) => Math.floor(new Date(d.getFullYear(), d.getMonth(), d.getDate() + days, h).getTime() / 1000);
+ const r = (guid, title, dueAt, parentGuid = null) => ({ guid, listGuid: "l1", title, notes: null, dueAt, allDay: false,
+ completedAt: null, priority: 0, flagged: false, parentGuid, etag: null });
+ window.__smartExtra = [r("par", "Plan the move", at(3, 10)), r("kid", "Book the van", at(5, 10), "par"), r("other", "Dentist", at(5, 9))];
+});
+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, remindersFixture: true });
+const page = await ctx.newPage();
+page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); failures++; });
+await page.goto(BASE, { waitUntil: "networkidle" });
+await openScreen(page, "Reminders");
+await page.locator(".rx-smart, .rx-tile, button", { hasText: "Scheduled" }).first().click();
+await page.waitForTimeout(600);
+const layout = await page.evaluate(() => {
+ const out = [];
+ let heading = null;
+ for (const el of document.querySelectorAll(".rx-section, .rx-row")) {
+ if (el.classList.contains("rx-section")) heading = el.textContent.trim();
+ else out.push([heading, el.querySelector(".rx-title")?.value]);
+ }
+ return out;
+});
+const p = layout.findIndex(([, t]) => t === "Plan the move"), k = layout.findIndex(([, t]) => t === "Book the van");
+ok(p >= 0 && k === p + 1 && layout[p][0] === layout[k][0], `the subtask is under its reminder ${JSON.stringify(layout)}`);
+await b.close();
+process.exitCode = failures ? 1 : 0;
diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsx
index b4635be..abf1de5 100644
--- a/src/screens/RemindersView.tsx
+++ b/src/screens/RemindersView.tsx
@@ -1472,16 +1472,27 @@ export function RemindersView() {
if (kind === "scheduled") {
const byDay = new Map<number, typeof threaded>();
const overdue: typeof threaded = [];
+ // A subtask goes with its reminder, directly under it, as in Today; one of a reminder not
+ // shown here (no date) stands on its own day.
+ let parentRows: typeof threaded | null = null;
for (const row of threaded) {
+ if (row.depth > 0 && parentRows) {
+ parentRows.push(row);
+ continue;
+ }
const due = row.reminder.dueAt;
- if (due === null) continue;
+ if (due === null) {
+ parentRows = null;
+ continue;
+ }
const days = daysApart(now, new Date(due * 1000));
- if (days < 0) overdue.push(row);
+ if (days < 0) parentRows = overdue;
else {
- const bucket = byDay.get(days);
- if (bucket) bucket.push(row);
- else byDay.set(days, [row]);
+ parentRows = byDay.get(days) ?? [];
+ byDay.set(days, parentRows);
}
+ parentRows.push(row);
+ if (row.depth > 0) parentRows = null;
}
const out = overdue.length
? [{ key: "overdue", heading: "Overdue", colour: null, dated: false, rows: overdue }]