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.

Notes: tap a checklist circle to tick or untick it — shown at once, written to that line alone, put back with the reason if refused

Yashwanth Kamireddi3a7f6d2ce438
diff --git a/.uiverify/notes-formatted.mjs b/.uiverify/notes-formatted.mjs
index f43e68e..9087705 100644
--- a/.uiverify/notes-formatted.mjs
+++ b/.uiverify/notes-formatted.mjs
@@ -16,7 +16,15 @@ const ticked = await page.locator(".nf-check.is-done").count();
const marks = await page.locator(".nf-mark").allInnerTexts();
ok(ticked === 1, `a ticked checklist item shows ticked [${ticked}]`);
ok(marks.length > 0 && marks.every((m) => m === "–"), `a dashed list shows its dashes ${JSON.stringify(marks.slice(0, 3))}`);
-await page.locator(".note-read").click();
+// A tap on a ticked circle unticks it at once, and asks Apple to.
+const circle = page.locator(".nf-check .nf-circle").first();
+await circle.click();
+await page.waitForTimeout(150);
+ok((await circle.getAttribute("aria-checked")) === "false", "a tap on a ticked circle unticks it at once");
+const sent = await page.evaluate(() => window.__paragraphs?.at(-1));
+ok(sent?.checked === false && typeof sent?.start === "number" && sent.start > 0, `and asks Apple for that line ${JSON.stringify(sent)}`);
+ok(await page.evaluate(() => document.activeElement?.tagName !== "TEXTAREA"), "a tick does not start editing");
+await page.locator(".nf-body, .nf-item:not(.nf-check)").first().click();
await page.waitForTimeout(200);
ok(await page.evaluate(() => document.activeElement?.classList.contains("note-text") && document.activeElement.tagName === "TEXTAREA"),
"a click into it is editing");
diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjs
index e277404..d70b9f4 100644
--- a/.uiverify/stub.mjs
+++ b/.uiverify/stub.mjs
@@ -168,6 +168,7 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
case "reminder_list_create": case "reminder_list_rename": case "reminder_list_delete":
return null;
case "reminders_smart": return !remindersFixture || remindersFixture === "lists" ? [] : reminderItems.filter(r => !r.completedAt);
+ case "note_paragraph": (window.__paragraphs ??= []).push(args); return null;
case "note_runs": {
// Curtains, set as a phone sets one: a title, then a dashed list and a ticked item.
if (args.guid !== "n1") return [];
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index be27721..c6743bc 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -997,6 +997,30 @@ async fn note_body(guid: String, data: State<'_, Data>) -> UiResult<Option<Strin
library.note_body(&guid).map_err(|e| e.to_string())
}
+/// Set one paragraph of a note: `style` from the Aa menu, or `checked` for a checklist tick.
+#[tauri::command]
+async fn note_paragraph(
+ guid: String,
+ start: u64,
+ style: Option<u64>,
+ checked: Option<bool>,
+ auth: State<'_, Auth>,
+ data: State<'_, Data>,
+) -> UiResult<()> {
+ use quince_icloud::ckdocument::ParagraphChange;
+ let change = match (style, checked) {
+ (Some(s), _) => ParagraphChange::Style(s),
+ (None, Some(c)) => ParagraphChange::Checked(c),
+ (None, None) => return Ok(()),
+ };
+ let (http, root, params) = cloudkit_context(&auth).await?;
+ let note = note_by_guid(&data, &guid).await?;
+ quince_icloud::notes::set_paragraph_cloudkit(&http, &root, params.clone(), &note, start, change)
+ .await
+ .map_err(|e| e.to_string())?;
+ resync_notes(&http, &root, params, &data).await
+}
+
/// How a note's text is set — Apple's attribute runs, in order — as stored at the last sync.
#[tauri::command]
async fn note_runs(guid: String, data: State<'_, Data>) -> UiResult<serde_json::Value> {
@@ -2409,6 +2433,7 @@ fn main() {
note_folder_delete,
note_body,
note_runs,
+ note_paragraph,
note_save,
note_create,
note_delete,
diff --git a/src/lib/ipc.ts b/src/lib/ipc.ts
index 40542d0..2c3a670 100644
--- a/src/lib/ipc.ts
+++ b/src/lib/ipc.ts
@@ -120,6 +120,8 @@ export const api = {
invoke<void>("reminder_delete", { guid, listGuid }),
noteFolders: () => invoke<NoteFolder[]>("note_folders"),
+ noteParagraph: (guid: string, start: number, change: { style?: number; checked?: boolean }) =>
+ invoke<void>("note_paragraph", { guid, start, ...change }),
noteRuns: (guid: string) => invoke<import("../screens/notes/Formatted").Run[]>("note_runs", { guid }),
noteFolderCreate: (title: string, parent: string | null) =>
invoke<string>("note_folder_create", { title, parent }),
diff --git a/src/screens/NotesView.tsx b/src/screens/NotesView.tsx
index 5f01372..fcc9201 100644
--- a/src/screens/NotesView.tsx
+++ b/src/screens/NotesView.tsx
@@ -193,6 +193,34 @@ export function NotesView() {
return () => { cancelled = true; };
}, [openGuid, revision]);
+ /**
+ * Tick a checklist item, as a tap on its circle does on the phone: shown at once, then
+ * written; a refusal puts the tick back and says why.
+ */
+ const tick = async (guid: string, start: number, checked: boolean) => {
+ const text = loadedBody?.guid === guid ? loadedBody.text : "";
+ const nl = text.indexOf("\n", start);
+ const end = nl < 0 ? text.length : nl + 1;
+ const flip = (on: boolean) =>
+ setLoadedRuns((cur) => {
+ if (!cur || cur.guid !== guid) return cur;
+ let at = 0;
+ const runs = cur.runs.map((r) => {
+ const inside = at >= start && at < end && r.style === 103;
+ at += r.length;
+ return inside ? { ...r, checked: on } : r;
+ });
+ return { guid, runs };
+ });
+ flip(checked);
+ try {
+ await api.noteParagraph(guid, start, { checked });
+ } catch (e) {
+ flip(!checked);
+ setError(messageOf(e));
+ }
+ };
+
/** What the open note says, or null while that is still unknown. */
const body = open && loadedBody?.guid === open.guid ? loadedBody.text : null;
const runs = open && loadedRuns?.guid === open.guid ? loadedRuns.runs : null;
@@ -823,7 +851,12 @@ export function NotesView() {
}
}}
>
- <FormattedBody text={body ?? ""} runs={runs ?? []} skip={titleLine.length + 1} />
+ <FormattedBody
+ text={body ?? ""}
+ runs={runs ?? []}
+ skip={titleLine.length + 1}
+ onTick={open ? (start, checked) => void tick(open.guid, start, checked) : undefined}
+ />
</div>
) : (
<LongTextarea