Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Reminders and Calendar: nothing waits on Apple, nothing greys out
Yashwanth Kamireddi0f083dea901b
diff --git a/.uiverify/calendar-instant.mjs b/.uiverify/calendar-instant.mjsindex e859474..5748cd1 100644--- a/.uiverify/calendar-instant.mjs+++ b/.uiverify/calendar-instant.mjs@@ -38,7 +38,8 @@ await page.waitForTimeout(300);const title = page.locator('input[placeholder="New Event"]').first();await title.fill("Dentist, again");await title.press("Enter");-await page.waitForTimeout(150);+await page.waitForTimeout(100);+ok((await page.locator(".cx-popover").count()) === 0, "Done closes the event at once, while Apple is still answering");ok(await page.locator(".cx-block", { hasText: "Dentist, again" }).count() > 0, "a retitled event shows its new title at once");await page.waitForTimeout(1800);const sent = await page.evaluate(() => window.__saves.at(-1));@@ -59,6 +60,16 @@ await page.waitForTimeout(1800);const linked = await page.evaluate(() => window.__saves.at(-1)?.draft?.url);ok(linked === "https://example.com/new", `a URL typed into the event is saved [${linked}]`);+// A new event is on the calendar the moment it is saved, before Apple has named it.+await page.getByRole("button", { name: "New event" }).click();+await page.waitForTimeout(250);+await page.locator('input[placeholder="New Event"]').first().fill("Coffee with Ana");+await page.locator('input[placeholder="New Event"]').first().press("Enter");+await page.waitForTimeout(100);+ok((await page.locator(".cx-popover").count()) === 0 && (await page.locator(".cx-block, .cx-chip, .cx-allday-chip", { hasText: "Coffee with Ana" }).count()) > 0,+ "a new event closes and is drawn at once, before Apple has answered");+await page.waitForTimeout(1800);+// A delete takes the event off the calendar at once.await page.locator(".cx-block", { hasText: "Design review" }).first().click();await page.waitForTimeout(250);diff --git a/.uiverify/reminders-tick.mjs b/.uiverify/reminders-tick.mjsindex cc4b8a1..036c70e 100644--- a/.uiverify/reminders-tick.mjs+++ b/.uiverify/reminders-tick.mjs@@ -16,11 +16,28 @@ const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failuawait page.evaluate(() => { window.__doneDelay = 4000; });const row = (t) => page.locator(".rx-row", { has: page.getByLabel(`Rename ${t}`) });+// Heights of the row frame by frame from the tick: it must fold (shrink over frames), not vanish.+await page.evaluate(() => {+ const r = [...document.querySelectorAll(".rx-row")].find((x) => x.querySelector('[aria-label="Rename Pick up the parcel"]'));+ window.__fold = [];+ const t0 = performance.now();+ const tick = () => {+ const h = r.isConnected ? Math.round(r.getBoundingClientRect().height) : -1;+ window.__fold.push([Math.round(performance.now() - t0), h]);+ if (h !== -1 && performance.now() - t0 < 2000) requestAnimationFrame(tick);+ };+ requestAnimationFrame(tick);+});await row("Pick up the parcel").locator(".rx-tick").click();await page.waitForTimeout(80);ok((await row("Pick up the parcel").locator(".rx-tick").getAttribute("aria-checked")) === "true", "the circle fills at once, while Apple is still answering");-await page.waitForTimeout(1500);-ok((await row("Pick up the parcel").count()) === 0, "and the row leaves after a moment, before Apple has answered");+ok(!(await row("Pick up the parcel").locator(".rx-title").isDisabled()), "and nothing on the row is greyed out while Apple answers");+await page.waitForTimeout(900);+ok((await row("Pick up the parcel").count()) === 0, "the row is gone within a moment, before Apple has answered");+const fold = await page.evaluate(() => window.__fold);+const full = fold[0][1];+const between = fold.filter(([, h]) => h > 0 && h < full - 2);+ok(between.length >= 3, `it folds away over several frames, not all at once ${JSON.stringify(fold.filter(([, h]) => h !== full))}`);await row("Plan tomorrow").locator(".rx-tick").click();await page.waitForTimeout(300);diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsxindex 6f44edb..a761718 100644--- a/src/screens/RemindersView.tsx+++ b/src/screens/RemindersView.tsx@@ -216,7 +216,6 @@ export function RemindersView() {const [showDone, setShowDone] = useState(false);const [syncing, setSyncing] = useState(false);/** Every reminder with a write still on its way — a set, since several can be at once. */- const [busy, setBusy] = useState<ReadonlySet<string>>(() => new Set());const [openGuid, setOpenGuid] = useState<string | null>(null);const [draft, setDraft] = useState("");const [newList, setNewList] = useState("");@@ -323,18 +322,26 @@ export function RemindersView() {* tap made every add, tick and delete feel a second behind. A refusal re-reads, which* puts the row back as it was, and says why.*/+ const queue = useRef(new Map<string, Promise<void>>());const write = useCallback(async (reminder: Reminder,run: () => Promise<void>,predict?: (rows: Reminder[]) => Reminder[],): Promise<Reminder[] | null> => {- setBusy((was) => new Set(was).add(reminder.guid));setError(null);if (predict) setItems((rows) => predict(rows));// Kept over any refresh until Apple has it; let go before the read that confirms it.const release = predict ? hold(predict) : () => {};+ // One reminder's changes reach Apple in the order they were made, each after the last —+ // so nothing on the row is ever disabled while one is on its way. (Disabled, the title+ // greyed out for the whole round trip, and a ticked reminder looked stuck.)+ const before = queue.current.get(reminder.guid) ?? Promise.resolve();+ let done = () => {};+ const mine = new Promise<void>((r) => (done = r));+ queue.current.set(reminder.guid, mine);try {+ await before;await run();release();return await readItems();@@ -344,12 +351,9 @@ export function RemindersView() {readItems().catch(() => {});return null;} finally {+ done();+ if (queue.current.get(reminder.guid) === mine) queue.current.delete(reminder.guid);release();- setBusy((was) => {- const next = new Set(was);- next.delete(reminder.guid);- return next;- });}},[readItems, hold],@@ -383,9 +387,28 @@ export function RemindersView() {};const depart = (guid: string) => {stay(guid);+ // A moment to see the tick land (and undo a mistaken one), then the row folds away: its+ // height closes as it fades, so the ones below glide up instead of jumping.departure.current.set(guid, [- window.setTimeout(() => setLeaving((was) => new Set(was).add(guid)), 900),- window.setTimeout(() => setDeparted((was) => new Set(was).add(guid)), 1200),+ window.setTimeout(() => {+ setLeaving((was) => new Set(was).add(guid));+ const row = document.querySelector<HTMLElement>(`.rx-row[data-guid="${CSS.escape(guid)}"]`);+ const still = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;+ if (!row || still || typeof row.animate !== "function") {+ setDeparted((was) => new Set(was).add(guid));+ return;+ }+ const h = row.getBoundingClientRect().height;+ const cs = getComputedStyle(row);+ const fold = row.animate(+ [+ { height: `${h}px`, paddingTop: cs.paddingTop, paddingBottom: cs.paddingBottom, opacity: 1 },+ { height: "0px", paddingTop: "0px", paddingBottom: "0px", opacity: 0 },+ ],+ { duration: 240, easing: "cubic-bezier(0.32, 0.72, 0, 1)", fill: "forwards" },+ );+ fold.onfinish = () => setDeparted((was) => new Set(was).add(guid));+ }, 600),]);};useEffect(() => {@@ -1198,7 +1221,7 @@ export function RemindersView() {go(e.key === "Home" ? 0 : rows.length - 1);} else if (e.key === " ") {e.preventDefault();- if (!busy.has(reminder.guid)) void toggle(reminder);+ void toggle(reminder);} else if (e.key === "Enter") {e.preventDefault();e.currentTarget.querySelector<HTMLInputElement>(".rx-title")?.focus();@@ -1260,7 +1283,7 @@ export function RemindersView() {defaultValue={reminder.title}key={`${reminder.guid}-${reminder.title}`}aria-label={`Rename ${reminder.title}`}- disabled={busy.has(reminder.guid)}+onBlur={(e) => void rename(reminder, e.target.value)}onKeyDown={(e) => {// As in Reminders on a Mac: Return finishes it and starts the next,@@ -1332,7 +1355,7 @@ export function RemindersView() {<Pickerlabel={`Repeat for ${reminder.title}`}value={repeatKey(reminder)}- disabled={busy.has(reminder.guid) || reminder.dueAt === null}+ disabled={reminder.dueAt === null}onChange={(key) => void setRepeat(reminder, key)}options={repeatKey(reminder) === "custom"@@ -1354,7 +1377,7 @@ export function RemindersView() {<Pickerlabel={`Priority for ${reminder.title}`}value={String(reminder.priority)}- disabled={busy.has(reminder.guid)}+onChange={(v) => void setPriority(reminder, Number(v))}options={PRIORITIES.map((p) => ({value: String(p.value),@@ -1367,7 +1390,7 @@ export function RemindersView() {<Pickerlabel={`List for ${reminder.title}`}value={reminder.listGuid}- disabled={busy.has(reminder.guid)}+onChange={(guid) => void moveToList(reminder, guid)}options={lists.map((l) => ({ value: l.guid, label: l.title }))}/>@@ -1384,7 +1407,7 @@ export function RemindersView() {{depth > 0 ? (<buttonclassName="rx-link"- disabled={busy.has(reminder.guid)}+onClick={() => void outdent(reminder)}>Move Out of Subtasks@@ -1392,7 +1415,7 @@ export function RemindersView() {) : (<buttonclassName="rx-link"- disabled={busy.has(reminder.guid)}+onClick={() => void indent(reminder)}>Make Subtask@@ -1401,7 +1424,7 @@ export function RemindersView() {<buttonclassName="rx-link danger"aria-label={`Delete ${reminder.title}`}- disabled={busy.has(reminder.guid)}+onClick={() => remove(reminder)}>Delete@@ -1428,7 +1451,7 @@ export function RemindersView() {reminder.flagged ? `Unflag ${reminder.title}` : `Flag ${reminder.title}`}aria-pressed={reminder.flagged}- disabled={busy.has(reminder.guid)}+onClick={() => flag(reminder)}><Glyph name="flagged" />diff --git a/src/screens/calendar/CalendarView.tsx b/src/screens/calendar/CalendarView.tsxindex a7cb509..aa43ba2 100644--- a/src/screens/calendar/CalendarView.tsx+++ b/src/screens/calendar/CalendarView.tsx@@ -269,7 +269,6 @@ export function CalendarView() {const [hidden, setHidden] = useState<Set<string>>(() => readSet(HIDDEN_KEY));const [loaded, setLoaded] = useState(false);const [error, setError] = useState<string | null>(null);- const [busy, setBusy] = useState(false);const [draft, setDraft] = useState<Draft | null>(null);const draftRef = useRef<Draft | null>(null);draftRef.current = draft;@@ -407,7 +406,6 @@ export function CalendarView() {*/const write = useCallback(async (run: () => Promise<void>, predict?: (rows: CalendarEvent[]) => CalendarEvent[]) => {- setBusy(true);setError(null);if (predict) setEvents((rows) => predict(rows));// Kept over any refresh until Apple has it; let go before the read that confirms it.@@ -424,7 +422,6 @@ export function CalendarView() {return false;} finally {release();- setBusy(false);}},[read, hold]@@ -469,11 +466,14 @@ export function CalendarView() {new Promise<EventScope | null>((answer) => setAsking({ verb, answer: (scope) => { setAsking(null); answer(scope); } }));const save = useCallback(- async (d: Draft) => {+ async (d: Draft, close = false) => {const occurrence = Boolean(d.guid && d.guid.includes("__"));// A repeat belongs to the series, so changing it is a change to all of it.const scope = occurrence ? (d.repeatChanged ? "all" : await whichEvents("change")) : null;if (occurrence && !scope) return false;+ // Closed the moment it is saved, drawn as saved, never waiting on Apple: kept open until+ // Apple answered, the popover hung for a second or two on every Done.+ if (close) setDraft(null);return write(async () => {await api.eventSave({...(scope ? { scope } : {}),@@ -492,7 +492,15 @@ export function CalendarView() {});}, (rows) => {// Shown where it now sits at once; a new one is drawn by its draft until Apple names it.- if (!d.guid) return rows;+ if (!d.guid) {+ return [...rows, {+ guid: `pending:${d.startsAt}:${d.title}`, calendarGuid: d.calendarGuid,+ title: d.title.trim() || "New Event", location: d.location.trim() || null,+ startsAt: d.startsAt, endsAt: Math.max(d.endsAt, d.startsAt + (d.allDay ? 86_400 : 900)),+ allDay: d.allDay, timezone: d.allDay ? ZONE : (d.timezone ?? ZONE),+ url: d.url?.trim() || null, notes: d.notes.trim() || null, etag: null,+ }];+ }// Future and All carry the words to the other days too; their times Apple settles.const series = d.guid.split("__")[0];const from = events.find((e) => e.guid === d.guid)?.startsAt ?? d.startsAt;@@ -992,12 +1000,9 @@ export function CalendarView() {draft={draft}at={anchor}calendars={calendars}- busy={busy}onChange={setDraft}onClose={() => setDraft(null)}- onSave={async () => {- if (await save(draft)) setDraft(null);- }}+ onSave={() => void save(draft, true)}onDelete={draft.guid ? () => void remove(draft.guid as string) : undefined}onNudge={draft.guid ? (by) => {// Calendar's Control-Option-arrows: the open event moves, stays open, and is saved.@@ -1834,7 +1839,6 @@ function EventPopover({draft,at,calendars,- busy,onChange,onClose,onSave,@@ -1845,7 +1849,6 @@ function EventPopover({draft: Draft;at: Anchor;calendars: Calendar[];- busy: boolean;onChange: (d: Draft) => void;onClose: () => void;onSave: () => void;@@ -2096,7 +2099,7 @@ function EventPopover({/><div className="cx-pop-actions">{onDelete && editable ? (- <button type="button" className="cx-pop-delete" onClick={onDelete} disabled={busy}>+ <button type="button" className="cx-pop-delete" onClick={onDelete}>Delete</button>) : (@@ -2107,7 +2110,7 @@ function EventPopover({{editable ? "Cancel" : "Close"}</button>{editable && (- <button type="submit" className="primary" disabled={busy}>+ <button type="submit" className="primary">{draft.guid ? "Save" : "Add"}</button>)}diff --git a/src/styles/reminders.css b/src/styles/reminders.cssindex 5a19116..d5b4286 100644--- a/src/styles/reminders.css+++ b/src/styles/reminders.css@@ -358,11 +358,10 @@background: var(--separator);}.rx-row:last-child::after { display: none; }-/* A ticked reminder on its way out, as on the phone: it fades and drifts up a little, on the- compositor only (opacity and transform), so nothing else is laid out while it goes. */-.rx-row { transition: opacity 260ms var(--ease, ease), transform 260ms var(--ease, ease); }-.rx-row.is-leaving { opacity: 0; transform: translateY(-4px); pointer-events: none; }-@media (prefers-reduced-motion: reduce) { .rx-row { transition: none; } }+/* A ticked reminder on its way out folds away — its height closing as it fades (see depart in+ RemindersView) — so the rows below glide up rather than jump. Nothing on it can be pressed+ meanwhile, and what is inside is clipped to the closing row. */+.rx-row.is-leaving { pointer-events: none; overflow: hidden; }/* A row chosen from the keyboard: the selection Reminders draws, a rounded tint behind it, withno outline drawn around the text. */.rx-row:focus { outline: none; }@@ -393,7 +392,11 @@inset: 2.5px;border-radius: 50%;background: var(--tick);+ /* The fill lands the instant it is pressed, with the quick spring Reminders gives it. */+ animation: rx-tick-in 220ms cubic-bezier(0.34, 1.56, 0.64, 1) both;}+@keyframes rx-tick-in { from { transform: scale(0.3); opacity: 0.4; } to { transform: scale(1); opacity: 1; } }+@media (prefers-reduced-motion: reduce) { .rx-tick[aria-checked="true"]::after { animation: none; } }.rx-tick.ghost {display: grid;place-items: center;