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: drag a reminder to reorder it in its list — shown where it is dropped at once, written to the list's order with its merge token advanced so the phone takes it — verified live
Yashwanth Kamireddib7797fd9b333
diff --git a/.uiverify/reminders-keys.mjs b/.uiverify/reminders-keys.mjsindex 8a607ce..7351701 100644--- a/.uiverify/reminders-keys.mjs+++ b/.uiverify/reminders-keys.mjs@@ -32,5 +32,22 @@ await page.getByLabel("Rename Pick up the parcel").focus();await page.keyboard.press("Enter");await page.waitForTimeout(150);ok(await page.evaluate(() => document.activeElement?.closest(".rx-add") !== null), "Return goes on to a new reminder");+// Drag to reorder: the row lands where it is dropped, at once, and Apple is asked.+const titles = () => page.locator(".rx-row:not(.is-done) .rx-title").evaluateAll((els) => els.map((e) => e.value));+const before = await titles();+const last = before.filter(Boolean).at(-1);+const src = page.locator(".rx-row", { has: page.getByLabel(`Rename ${last}`) });+const dst = page.locator(".rx-row").first();+await src.dragTo(dst);+await page.waitForTimeout(200);+const after = await titles();+ok(after[0] === last, `a dragged reminder lands where it is dropped ${JSON.stringify(after.slice(0, 3))}`);+const asked = await page.evaluate(() => window.__reorders?.at(-1));+ok(asked && asked.before, `and Apple is asked to put it there ${JSON.stringify(asked)}`);+// Typing in a title still types, in a row that can be dragged.+await page.getByLabel(`Rename ${last}`).click();+await page.keyboard.press("End");+await page.keyboard.type("!");+ok((await page.getByLabel(`Rename ${last}`).inputValue()).endsWith("!"), "a reminder's title still takes typing");await b.close();process.exitCode = failures ? 1 : 0;diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjsindex 73f6952..a616da2 100644--- a/.uiverify/stub.mjs+++ b/.uiverify/stub.mjs@@ -169,6 +169,14 @@ export function installStub({ screen, services, twoFactor, calendarFixture, noteif (r) for (const [k, v] of Object.entries(args.edit)) if (k !== "listGuid") r[k] = v;return null;}+ case "reminder_reorder": {+ (window.__reorders ??= []).push(args);+ const i = reminderItems.findIndex((x) => x.guid === args.guid);+ const [moved] = reminderItems.splice(i, 1);+ const at = reminderItems.findIndex((x) => x.guid === args.before);+ reminderItems.splice(at < 0 ? reminderItems.length : at, 0, moved);+ return null;+ }case "reminder_list_colour": {(window.__listColours ??= []).push([args.listGuid, args.colour]);const hex = { purple: "#C077DB", red: "#FF3B30", blue: "#007AFF" }[args.colour];diff --git a/crates/quince-icloud/src/reminders.rs b/crates/quince-icloud/src/reminders.rsindex 2f20757..c06707e 100644--- a/crates/quince-icloud/src/reminders.rs+++ b/crates/quince-icloud/src/reminders.rs@@ -1177,6 +1177,49 @@ pub async fn create_cloudkit(}/// Add a reminder to the end of a list's `ReminderIDs`, and take it out of the list it left.+/// Move a reminder within its list's own order, before `before` — or to the end — as a drag+/// in Reminders does. The order is the list's `ReminderIDs`; written with its merge token+/// advanced, so the phone takes the new order rather than keeping its own.+pub async fn reorder_cloudkit(+ http: &reqwest::Client,+ ckdatabasews_root: &str,+ params: Vec<(String, String)>,+ list_guid: &str,+ reminder_guid: &str,+ before: Option<&str>,+) -> Result<()> {+ let bare = |g: &str| g.rsplit('/').next().unwrap_or(g).to_string();+ let id = bare(reminder_guid);+ let client = ZoneClient::new(http, ckdatabasews_root, CONTAINER, params);+ let list = client+ .lookup_record(ZONE, list_guid)+ .await?+ .ok_or_else(|| Error::Refused("That list is no longer in iCloud.".into()))?;+ let mut ids: Vec<String> = list+ .pointer("/fields/ReminderIDs/value")+ .and_then(Value::as_str)+ .and_then(|s| serde_json::from_str(s).ok())+ .unwrap_or_default();+ ids.retain(|x| !x.eq_ignore_ascii_case(&id));+ let at = before+ .map(bare)+ .and_then(|b| ids.iter().position(|x| x.eq_ignore_ascii_case(&b)))+ .unwrap_or(ids.len());+ ids.insert(at, id);+ client+ .update_record_signed(+ ZONE,+ list_guid,+ "List",+ None,+ serde_json::json!({+ "ReminderIDs": { "type": "STRING", "value": serde_json::to_string(&ids).unwrap_or_default() }+ }),+ )+ .await?;+ Ok(())+}+async fn place_in_list(client: &ZoneClient<'_>,list_guid: &str,diff --git a/probe/examples/reminders_reorder.rs b/probe/examples/reminders_reorder.rsnew file mode 100644index 0000000..e4b03af--- /dev/null+++ b/probe/examples/reminders_reorder.rs@@ -0,0 +1,27 @@+//! Live, throwaway list only: three reminders, the last moved to the front, the order read+//! back from Apple — then the list deleted.+use anyhow::{anyhow, Result};+#[tokio::main]+async fn main() -> Result<()> {+ let dir = std::path::PathBuf::from(std::env::var("HOME")?).join(".local/share/quince-probe");+ let mut client = quince_auth::Client::new(&dir)?;+ if !client.resume().await? { return Err(anyhow!("no session")); }+ let root = client.session().service_url("ckdatabasews").ok_or_else(|| anyhow!("no ckdatabasews"))?;+ let (http, p) = (client.http().clone(), client.service_params());+ use quince_icloud::reminders as r;+ let list = r::create_list_cloudkit(&http, &root, p.clone(), "Quince order test").await?;+ let a = r::create_cloudkit(&http, &root, p.clone(), &list, "A").await?;+ let _b = r::create_cloudkit(&http, &root, p.clone(), &list, "B").await?;+ let c = r::create_cloudkit(&http, &root, p.clone(), &list, "C").await?;+ let zc = quince_icloud::cloudkit::ZoneClient::new(&http, &root, "com.apple.reminders", p.clone());+ let order = |v: serde_json::Value| v["fields"]["ReminderIDs"]["value"].as_str().unwrap_or("").to_string();+ println!("made: {}", order(zc.lookup_record("Reminders", &list).await?.unwrap()));+ r::reorder_cloudkit(&http, &root, p.clone(), &list, &c, Some(&a)).await?;+ let after = zc.lookup_record("Reminders", &list).await?.unwrap();+ println!("moved: {}", order(after.clone()));+ let rtm: serde_json::Value = serde_json::from_str(after["fields"]["ResolutionTokenMap"]["value"].as_str().unwrap_or("{}"))?;+ println!("order token: {}", rtm["map"]["reminderIDsMergeableOrdering"]);+ r::delete_list_cloudkit(&http, &root, p, &list).await?;+ println!("deleted");+ Ok(())+}diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rsindex 0dab3a9..d23571f 100644--- a/src-tauri/src/main.rs+++ b/src-tauri/src/main.rs@@ -971,6 +971,29 @@ async fn reminder_list_rename(resync_reminders(&http, &root, params, &data).await}+/// Move a reminder within its list, before another or to the end, as a drag does.+#[tauri::command]+async fn reminder_reorder(+ list_guid: String,+ guid: String,+ before: Option<String>,+ auth: State<'_, Auth>,+ data: State<'_, Data>,+) -> UiResult<()> {+ let (http, root, params) = cloudkit_context(&auth).await?;+ quince_icloud::reminders::reorder_cloudkit(+ &http,+ &root,+ params.clone(),+ &list_guid,+ &guid,+ before.as_deref(),+ )+ .await+ .map_err(|e| e.to_string())?;+ resync_reminders(&http, &root, params, &data).await+}+/// A list's colour, one of Apple's twelve, as Show List Info sets it.#[tauri::command]async fn reminder_list_colour(@@ -2494,6 +2517,7 @@ fn main() {reminder_list_rename,reminder_list_delete,reminder_list_colour,+ reminder_reorder,note_folders,note_folder_create,note_folder_rename,diff --git a/src/lib/ipc.ts b/src/lib/ipc.tsindex 133f462..994f65c 100644--- a/src/lib/ipc.ts+++ b/src/lib/ipc.ts@@ -104,6 +104,8 @@ export const api = {reminderListCreate: (title: string) => invoke<void>("reminder_list_create", { title }),reminderListRename: (listGuid: string, title: string) =>invoke<void>("reminder_list_rename", { listGuid, title }),+ reminderReorder: (listGuid: string, guid: string, before: string | null) =>+ invoke<void>("reminder_reorder", { listGuid, guid, before }),reminderListColour: (listGuid: string, colour: string) =>invoke<void>("reminder_list_colour", { listGuid, colour }),reminderListDelete: (listGuid: string) =>diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsxindex de144a1..ca3116b 100644--- a/src/screens/RemindersView.tsx+++ b/src/screens/RemindersView.tsx@@ -416,6 +416,27 @@ export function RemindersView() {);};+ /** Drag and drop: what is being dragged, and the row it would land before. */+ const [dragging, setDragging] = useState<string | null>(null);+ const [dropBefore, setDropBefore] = useState<string | null>(null);+ const canReorder = inList && !searching;+ /** Put a reminder before another in its list — at once, then to Apple; back if refused. */+ const reorder = (guid: string, before: string) => {+ const r = items.find((x) => x.guid === guid);+ if (!r || !listGuid) return Promise.resolve(null);+ return write(+ r,+ () => api.reminderReorder(listGuid, guid, before),+ (rows) => {+ const moved = rows.find((x) => x.guid === guid);+ if (!moved) return rows;+ const rest = rows.filter((x) => x.guid !== guid);+ const at = rest.findIndex((x) => x.guid === before);+ return [...rest.slice(0, at < 0 ? rest.length : at), moved, ...rest.slice(at < 0 ? rest.length : at)];+ },+ );+ };+const outdent = (r: Reminder) =>write(r,@@ -1075,7 +1096,31 @@ export function RemindersView() {key={reminder.guid}className={`rx-row${reminder.completedAt ? " is-done" : ""}${depth > 0 ? " is-subtask" : ""- }${isOpen ? " is-open" : ""}`}+ }${isOpen ? " is-open" : ""}${dropBefore === reminder.guid ? " is-drop-before" : ""}${+ dragging === reminder.guid ? " is-dragging" : ""+ }`}+ // Drag to reorder, in a list, as Reminders does — open ones among themselves.+ draggable={canReorder && depth === 0 && !reminder.completedAt}+ onDragStart={(e) => {+ if (!canReorder) return;+ e.dataTransfer.effectAllowed = "move";+ e.dataTransfer.setData("text/plain", reminder.guid);+ setDragging(reminder.guid);+ }}+ onDragEnd={() => { setDragging(null); setDropBefore(null); }}+ onDragOver={(e) => {+ if (!dragging || dragging === reminder.guid || depth > 0 || reminder.completedAt) return;+ e.preventDefault();+ e.dataTransfer.dropEffect = "move";+ if (dropBefore !== reminder.guid) setDropBefore(reminder.guid);+ }}+ onDrop={(e) => {+ e.preventDefault();+ const moving = dragging;+ setDragging(null);+ setDropBefore(null);+ if (moving && moving !== reminder.guid) void reorder(moving, reminder.guid);+ }}><buttonclassName="rx-tick"diff --git a/src/styles/reminders.css b/src/styles/reminders.cssindex bbd9a89..d7c1a46 100644--- a/src/styles/reminders.css+++ b/src/styles/reminders.css@@ -559,3 +559,8 @@.rx-switch input:checked + .rx-switch-track::after { transform: translateX(14px); }.rx-switch input:focus-visible + .rx-switch-track { outline: 2px solid var(--sys-blue); outline-offset: 2px; }.rx-switch input:disabled + .rx-switch-track { opacity: 0.4; }++/* Dragging: the row lifted, and a line where it would land, as Reminders draws them. */+.rx-row[draggable="true"] { cursor: grab; }+.rx-row.is-dragging { opacity: 0.45; }+.rx-row.is-drop-before { box-shadow: inset 0 2px 0 var(--sys-blue, #0a84ff); }