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
Contacts: deleting inside a list asks Remove from List or Delete Card, as icloud.com does
Yashwanth Kamireddi29623373b0e1
diff --git a/.uiverify/contacts-lists.mjs b/.uiverify/contacts-lists.mjsindex acec60c..5a9367f 100644--- a/.uiverify/contacts-lists.mjs+++ b/.uiverify/contacts-lists.mjs@@ -95,10 +95,22 @@ await page.waitForTimeout(quick);check((await row("Office").count()) === 0, "a deleted list leaves the column at once");await page.waitForTimeout(900);+// Delete, inside a list, asks: out of the list, or the card everywhere.+await row("Family").locator(".notes-folder").click();+await page.locator(".contact-row", { hasText: "Amma" }).click();+await page.locator(".contact-detail").getByRole("button", { name: "Delete", exact: true }).click();+const asked = page.getByRole("alertdialog", { name: "Delete contact" });+check(await asked.isVisible(), "deleting inside a list asks which is meant");+await asked.getByRole("button", { name: "Remove from List" }).click();+await page.waitForTimeout(quick);+check((await count("Family")) === 1 && !(await people()).includes("Amma"), "Remove from List takes them out at once");+check(!(await page.evaluate(() => window.__contactDeletes?.length)), "and the card itself is left alone");+await page.waitForTimeout(900);+const writes = await page.evaluate(() => window.__listWrites);check(JSON.stringify(writes.map((w) => Object.keys(w).sort().join(","))) ===- JSON.stringify(["add,guid", "add,name", "add,guid", "guid,name", "guid,remove", "add,guid", "delete,guid"]),+ JSON.stringify(["add,guid", "add,name", "add,guid", "guid,name", "guid,remove", "add,guid", "delete,guid", "guid,remove"]),"each change goes to Apple as what changed, not a guessed whole list");diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjsindex 7b0a854..9cc626c 100644--- a/.uiverify/stub.mjs+++ b/.uiverify/stub.mjs@@ -233,7 +233,7 @@ export function installStub({ screen, services, twoFactor, calendarFixture, notereturn [noteList.length, [...per.entries()]];}case "contact_save": (window.__contactSaves ??= []).push(args); return "C-new";- case "contact_delete": return null;+ case "contact_delete": (window.__contactDeletes ??= []).push(args); return null;case "contacts_list": return !contactsFixture ? [] : contactList;case "contact_lists": return !contactsFixture ? [] : (window.__lists ??= [{ guid: "L1", name: "Family", members: ["c2"], etag: "e1" },diff --git a/src/screens/ContactsView.tsx b/src/screens/ContactsView.tsxindex 903bebf..504cd16 100644--- a/src/screens/ContactsView.tsx+++ b/src/screens/ContactsView.tsx@@ -13,6 +13,7 @@ import {import { useSync } from "../lib/sync";import { Picker } from "../components/Picker";import { RowMenu, type MenuEntry } from "../components/RowMenu";+import { Portal } from "../components/Portal";/** The sidebar row that is every contact rather than a list. */const ALL = "";@@ -107,6 +108,8 @@ export function ContactsView() {const [listMenu, setListMenu] = useState<(MenuAt & { list: ContactList }) | null>(null);/** A contact's menu: its actions, or — one step in — the lists it can go into. */const [contactMenu, setContactMenu] = useState<(MenuAt & { contact: Contact; lists: boolean }) | null>(null);+ /** A contact being deleted while a list is open: out of the list, or gone everywhere? */+ const [deleting, setDeleting] = useState<Contact | null>(null);const [dragging, setDragging] = useState<string | null>(null);const [dropOn, setDropOn] = useState<string | null>(null);/** List writes go to Apple one after another, in the order they were made. */@@ -244,7 +247,7 @@ export function ContactsView() {null,{ label: "Edit Contact", run: () => { setOpenGuid(c.guid); setDraft({ ...c }); } },{ label: "Delete Contact\u2026", danger: true, run: () => {- if (window.confirm(`Delete ${displayName(c)}?`)) void removeContact(c.guid);+ askDelete(c);} },];};@@ -282,6 +285,15 @@ export function ContactsView() {}}, [draft, write]);+ /**+ * Deleting a person is not something to discover by accident. Inside a list, icloud.com+ * asks whether the card goes or only its place in the list — the same here.+ */+ const askDelete = (c: Contact) => {+ if (openList) setDeleting(c);+ else if (window.confirm(`Delete ${displayName(c)}?`)) void removeContact(c.guid);+ };+const removeContact = useCallback(async (guid: string) => {if (await write(() => api.contactDelete(guid))) setDraft(null);@@ -441,6 +453,26 @@ export function ContactsView() {{loaded && shown.length === 0 && !error && (<p className="cal-empty">{search ? "No matches." : openList ? "No one in this list yet." : "No contacts yet."}</p>)}+ {deleting && openList && (+ <Portal>+ <div className="modal-veil" onClick={() => setDeleting(null)}>+ <div className="modal-sheet cx-ask" role="alertdialog" aria-label="Delete contact" onClick={(e) => e.stopPropagation()}+ onKeyDown={(e) => { if (e.key === "Escape") setDeleting(null); }}>+ <h2>Delete {displayName(deleting)}?</h2>+ <p>Remove this contact from “{openList.name}”, or delete the card from Contacts on every device.</p>+ <div className="cx-ask-actions">+ <button className="primary" autoFocus onClick={() => { const c = deleting; setDeleting(null); removeFromList(openList, [c.guid]); }}>+ Remove from List+ </button>+ <button className="quiet danger" onClick={() => { const c = deleting; setDeleting(null); void removeContact(c.guid); }}>+ Delete Card+ </button>+ <button className="quiet" onClick={() => setDeleting(null)}>Cancel</button>+ </div>+ </div>+ </div>+ </Portal>+ )}{contactMenu && (<RowMenuat={contactMenu}@@ -682,12 +714,7 @@ export function ContactsView() {<buttonclassName="quiet danger"disabled={busy}- onClick={() => {- // Deleting a person is not something to discover by accident.- if (window.confirm(`Delete ${displayName(open)}?`)) {- void removeContact(open.guid);- }- }}+ onClick={() => askDelete(open)}>Delete</button>