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: redraws only the cards a pass changed, writes instantly, names as the Mac does
Yashwanth Kamireddiadfe7e59c358
diff --git a/.uiverify/contacts-instant.mjs b/.uiverify/contacts-instant.mjsnew file mode 100644index 0000000..68d3882--- /dev/null+++ b/.uiverify/contacts-instant.mjs@@ -0,0 +1,106 @@+// Contacts' writes are instant, as every write here is: a card saved shows as saved the moment+// Save is pressed — the form away, the name in the list — and a card deleted is gone at once,+// however long the library takes behind. Turned down, the card goes back to what it was and+// the form returns as it was being written. And the list names people as the Mac does, the+// part they are sorted by in bold; Ctrl+L edits the card and Ctrl+Shift+N makes a list.+import { engine, engineName } from "./engine.mjs";+import { SERVICES, autoConfirm, installStub, openScreen } from "./stub.mjs";+const b = await engine.launch();+const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, contactsFixture: true });+await ctx.addInitScript(autoConfirm);+await ctx.addInitScript(() => {+ // The library slow to take a write (a pass storing ahead of it), or turning it down.+ const internals = window.__TAURI_INTERNALS__;+ const invoke = internals.invoke;+ internals.invoke = async (cmd, args) => {+ if (cmd === "contact_save" || cmd === "contact_delete") {+ await new Promise((r) => setTimeout(r, window.__slow ?? 0));+ if (window.__refuse) throw "The library couldn’t be saved.";+ const out = await invoke(cmd, args);+ const book = window.__contactList;+ if (cmd === "contact_delete") book.splice(book.findIndex((c) => c.guid === args.guid), 1);+ else {+ const card = { ...args.contact, guid: args.contact.guid || "C-new" };+ const at = book.findIndex((c) => c.guid === card.guid);+ if (at >= 0) book[at] = card;+ else book.push(card);+ }+ return out;+ }+ return invoke(cmd, args);+ };+});+const page = await ctx.newPage();+page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); process.exitCode = 1; });+await page.goto(process.env.BASE ?? "http://localhost:4173", { waitUntil: "networkidle" });+await openScreen(page, "Contacts");+await page.locator(".contact-row", { hasText: "Zoya Ahuja" }).waitFor();+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${engineName}: ${m}`); if (!p) failures++; };+const names = () => page.locator(".contact-row .contact-row-name").allInnerTexts();+const bold = (name) => page.locator(".contact-row .contact-row-name", { hasText: name }).evaluate((e) => e.querySelector("b")?.textContent ?? null);++// The Mac's list: the sorted-by part in bold.+ok((await bold("Zoya Ahuja")) === "Ahuja", "a person's last name is in bold");+ok((await bold("Northfield University")) === "Northfield University", "a company's name is in bold");+ok((await bold("Amma")) === "Amma", "a first name alone is in bold");+ok((await bold("+91 90000 11111")) === null, "a card with only a number is plain");++// Ctrl+L edits the card open.+await page.locator(".contact-row", { hasText: "Zoya Ahuja" }).click();+await page.keyboard.press("Control+l");+ok(await page.locator(".contact-form h2", { hasText: "Edit contact" }).isVisible(), "Ctrl+L edits the card");++// Saved with the library slow: shown as saved at once.+await page.evaluate(() => { window.__slow = 1500; });+await page.getByLabel("Last", { exact: true }).fill("Rivera");+const t0 = Date.now();+await page.getByRole("button", { name: "Save" }).click();+await page.locator(".contact-row", { hasText: "Zoya Rivera" }).waitFor({ timeout: 1000 });+const took = Date.now() - t0;+ok(took < 1000 && (await page.locator(".contact-form").count()) === 0, `an edit shows as saved at once, the form away (${took} ms)`);+ok((await page.locator(".contact-detail h2").innerText()) === "Zoya Rivera", "the card shows it");+await page.waitForTimeout(1700);+ok((await names()).includes("Zoya Rivera"), "and it stays once the library has it");++// A new card: in the list and open at once.+await page.keyboard.press("Control+n");+await page.getByLabel("First", { exact: true }).fill("Maya");+await page.getByLabel("Last", { exact: true }).fill("Silva");+await page.getByRole("button", { name: "Add contact" }).click();+await page.locator(".contact-row", { hasText: "Maya Silva" }).waitFor({ timeout: 1000 });+ok((await page.locator(".contact-detail h2").innerText()) === "Maya Silva", "a new card is in the list and open at once");+await page.waitForTimeout(1700);+ok((await page.locator('.contact-row[aria-selected="true"]').getAttribute("data-guid")) === "C-new", "and keeps its place under the id it is given");++// Deleted: gone at once.+await page.locator(".contact-row", { hasText: "Amma" }).click();+await page.keyboard.press("Delete");+await page.waitForFunction(() => ![...document.querySelectorAll(".contact-row")].some((r) => r.textContent.includes("Amma")), null, { timeout: 1000 })+ .then(() => ok(true, "a card deleted is gone at once"), () => ok(false, "a card deleted is gone at once"));+await page.waitForTimeout(1700);++// Turned down: back as it was, the form back as it was being written.+await page.evaluate(() => { window.__slow = 300; window.__refuse = true; });+await page.locator(".contact-row", { hasText: "Northfield University" }).click();+await page.keyboard.press("Enter");+await page.getByLabel("Company", { exact: true }).fill("Northfield College");+await page.getByRole("button", { name: "Save" }).click();+await page.locator(".contact-row", { hasText: "Northfield College" }).waitFor({ timeout: 1000 });+await page.locator(".contact-form").waitFor({ timeout: 3000 });+ok((await page.getByLabel("Company", { exact: true }).inputValue()) === "Northfield College", "turned down, the form comes back as it was being written");+ok((await names()).includes("Northfield University") && !(await names()).includes("Northfield College"), "and the card in the list is as it was");+ok(await page.locator(".toast", { hasText: "couldn’t be saved" }).isVisible(), "with why, said");+await page.keyboard.press("Escape");+await page.locator(".contact-row", { hasText: "+91 90000 11111" }).click();+await page.keyboard.press("Delete");+await page.waitForTimeout(800);+ok((await names()).includes("+91 90000 11111"), "a delete turned down puts the card back");+await page.evaluate(() => { window.__refuse = false; window.__slow = 0; });++// Ctrl+Shift+N names a new list in place.+await page.keyboard.press("Control+Shift+N");+ok(await page.locator(".contacts-lists input.notes-folder-rename").isVisible(), "Ctrl+Shift+N starts a new list, its name being typed");+await b.close();+process.exitCode = failures ? 1 : (process.exitCode ?? 0);diff --git a/.uiverify/contacts-items.mjs b/.uiverify/contacts-items.mjsnew file mode 100644index 0000000..4d06eb6--- /dev/null+++ b/.uiverify/contacts-items.mjs@@ -0,0 +1,98 @@+// A pass that names the cards it changed has Contacts read those alone: the card renamed on+// the phone is redrawn, the new one appears, the deleted one goes — and the whole book is not+// read again, nor any other row redrawn. One that cannot name them is read whole, as before;+// and out of sight, the named cards wait for the screen to come back.+import { engine, engineName } from "./engine.mjs";+import { SERVICES, installStub, openScreen } from "./stub.mjs";+const b = await engine.launch();+const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, contactsFixture: true });+await ctx.addInitScript(() => {+ const internals = window.__TAURI_INTERNALS__;+ const invoke = internals.invoke;+ internals.invoke = async (cmd, args) => {+ if (cmd === "contacts_list") window.__reads = (window.__reads ?? 0) + 1;+ if (cmd === "contacts_get") (window.__gets ??= []).push(args.guids);+ return invoke(cmd, args);+ };+});+const page = await ctx.newPage();+page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); process.exitCode = 1; });+await page.goto(process.env.BASE ?? "http://localhost:4173", { waitUntil: "networkidle" });+await openScreen(page, "Contacts");+await page.locator(".contact-row", { hasText: "Zoya Ahuja" }).waitFor();+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${engineName}: ${m}`); if (!p) failures++; };+const reads = () => page.evaluate(() => window.__reads ?? 0);+const gets = () => page.evaluate(() => window.__gets ?? []);+const names = () => page.locator(".contact-row .contact-row-name").allInnerTexts();+const pass = (items) => page.evaluate((items) => window.__emit("quince://synced", {+ services: [], asOf: null, tookMs: 0, changed: ["contacts"], ...(items ? { items: { contacts: items } } : {}),+}), items);++// Mark a row that the pass should leave alone, to see that it is not drawn again.+await page.locator(".contact-row", { hasText: "Amma" }).evaluate((e) => { e.__untouched = true; });++// On the phone: Zoya renamed, a card added, the unnamed number deleted.+await page.evaluate(() => {+ const book = window.__contactList;+ // Replaced, not changed in place: the stub hands its own objects to the page.+ const at = book.findIndex((c) => c.guid === "c1");+ book[at] = { ...book[at], lastName: "Rivera" };+ book.push({ guid: "c9", firstName: "Maya", lastName: "Silva", company: null, isCompany: false, birthday: null, notes: null, etag: null, methods: [] });+ book.splice(book.findIndex((c) => c.guid === "c4"), 1);+});+let before = await reads();+await pass({ added: ["c9"], changed: ["c1"], removed: ["c4"] });+await page.locator(".contact-row", { hasText: "Maya Silva" }).waitFor({ timeout: 3000 });+await page.locator(".contact-row", { hasText: "Zoya Rivera" }).waitFor({ timeout: 3000 });+const now = await names();+ok(now.includes("Zoya Rivera") && !now.includes("Zoya Ahuja"), `the card renamed on the phone is redrawn ${JSON.stringify(now)}`);+ok(now.includes("Maya Silva"), "the card added appears");+ok(!now.includes("+91 90000 11111"), "the card deleted goes");+ok((await reads()) === before, "and the whole book is not read again");+ok(JSON.stringify((await gets()).at(-1)?.slice().sort()) === JSON.stringify(["c1", "c9"]), `only the cards named are read ${JSON.stringify(await gets())}`);+ok(await page.locator(".contact-row", { hasText: "Amma" }).evaluate((e) => e.__untouched === true), "every other row is left as it was");+ok((await page.locator(".contact-detail h2").innerText()) === "Zoya Rivera", "the open card shows the change");++// A pass that can't name its cards: read whole.+before = await reads();+await pass(null);+await page.waitForFunction((n) => (window.__reads ?? 0) > n, before, { timeout: 3000 }).catch(() => {});+ok((await reads()) === before + 1, "one that cannot name them is read whole, once");++// A pass that changed nothing it shows is not read at all.+before = await reads();+const g = (await gets()).length;+await pass({ added: [], changed: [], removed: [] });+await page.waitForTimeout(250);+ok((await reads()) === before && (await gets()).length === g, "one that names no card reads nothing");++// Out of sight: named cards wait, and are read once on coming back.+await openScreen(page, "Notes");+await page.evaluate(() => {+ const book = window.__contactList;+ const at = book.findIndex((c) => c.guid === "c2");+ book[at] = { ...book[at], firstName: "Amma Jamie" };+});+const g2 = (await gets()).length;+before = await reads();+await pass({ added: [], changed: ["c2"], removed: [] });+await pass({ added: [], changed: ["c3"], removed: [] });+await page.waitForTimeout(250);+ok((await gets()).length === g2, "out of sight, named cards are not read at once");+await openScreen(page, "Contacts");+await page.locator(".contact-row", { hasText: "Amma Jamie" }).waitFor({ timeout: 3000 });+const after = await gets();+ok(after.length === g2 + 1 && after.at(-1).slice().sort().join() === "c2,c3", `coming back reads them, together, once ${JSON.stringify(after.slice(g2))}`);+ok((await reads()) === before, "still without the whole book");++// With a search typed, the search is run again: it decides who shows.+await page.locator(".contacts-search input").fill("Maya");+await page.waitForFunction(() => document.querySelectorAll(".contact-row").length === 1, null, { timeout: 3000 }).catch(() => {});+before = await reads();+await pass({ added: [], changed: ["c9"], removed: [] });+await page.waitForFunction((n) => (window.__reads ?? 0) > n, before, { timeout: 3000 }).catch(() => {});+ok((await reads()) === before + 1, "with a search typed, the search is run again");+await b.close();+process.exitCode = failures ? 1 : (process.exitCode ?? 0);diff --git a/src/components/ShortcutsSheet.tsx b/src/components/ShortcutsSheet.tsxindex a76d395..1acaf5a 100644--- a/src/components/ShortcutsSheet.tsx+++ b/src/components/ShortcutsSheet.tsx@@ -60,6 +60,9 @@ export const SHORTCUTS: { app: string; key: string; rows: Row[] }[] = [key: "contacts",rows: [[[["Ctrl", "N"]], "New contact"],+ [[["Ctrl", "Shift", "N"]], "New list"],+ [[["Ctrl", "L"], ["Return"]], "Edit contact"],+ [[["Delete"]], "Delete contact"],[[["Ctrl", "F"]], "Search"],[[["Ctrl", "A"]], "Select all"],],diff --git a/src/screens/ContactsView.tsx b/src/screens/ContactsView.tsxindex df3d442..05b4c19 100644--- a/src/screens/ContactsView.tsx+++ b/src/screens/ContactsView.tsx@@ -21,9 +21,10 @@ import {type AddressEdit,type AddressPart,type PostalAddress,+ type ItemChanges,} from "../lib/ipc";import { Arriving } from "../components/EmptyState";-import { useArriving, useRevision } from "../lib/sync";+import { useArriving, useItemChanges } from "../lib/sync";import { overlayOpen, useActiveRef, useScreenActive } from "../lib/screen";import { Picker } from "../components/Picker";import { RowMenu, type MenuEntry } from "../components/RowMenu";@@ -168,13 +169,12 @@ export function ContactsView() {const [error, setError] = useState<string | null>(null);useErrorToast(error, () => setError(null));const [confirm, confirmSheet] = useConfirm();- const revision = useRevision("contacts");- // A pass that lands while another screen is in front is read when this one comes back, once,- // not at every landing: a screen out of sight stays mounted (lib/screen).+ // A pass that names the cards it changed has those alone read again (`patch`, below); one+ // that can't say moves `due`, and the book is read whole. Either, landing while another+ // screen is in front, is taken when this one comes back, once (lib/sync, lib/screen).+ const patch = useRef<(items: ItemChanges) => void>(() => {});+ const due = useItemChanges("contacts", (items) => patch.current(items));const active = useScreenActive();- const seen = useRef(revision);- if (active) seen.current = revision;- const due = seen.current;const arriving = useArriving("contacts");/** The card being written, or null while simply looking. */const [draft, setDraft] = useState<Contact | null>(null);@@ -300,14 +300,27 @@ export function ContactsView() {const tickDue = seenTick.current;/** Each read is numbered: one overtaken by a later one (a key typed since) never draws. */const reads = useRef(0);+ /** Whole reads on their way: a pass's cards landing meanwhile are read whole too (`patch`). */+ const reading = useRef(0);const read = useCallback(async (query: string) => {const mine = ++reads.current;- const found = await api.contactsList(query.trim() || null);+ reading.current += 1;+ let found: Contact[];+ try {+ found = await api.contactsList(query.trim() || null);+ } finally {+ reading.current -= 1;+ }if (mine !== reads.current) return;// Each card unchanged keeps its row as it was (lib/same).setContacts((was) => keepSame(was, Array.isArray(found) ? found : [], (c) => c.guid));setLoaded(true);}, []);+ /** The book as last drawn, for a handler that runs after awaiting something. */+ const shownBook = useRef(contacts);+ shownBook.current = contacts;+ /** Moves when the open card was among those a pass changed: its addresses are read again. */+ const [cardRead, setCardRead] = useState(0);// The library is the only thing this screen reads. `revision` ticks whenever a refresh// finishes — pressed or on the timer — so a change made on the phone lands here without@@ -415,6 +428,49 @@ export function ContactsView() {useEffect(() => {readDupes().catch(() => {});}, [readDupes, due, tickDue]);+ /**+ * A pass that named the cards it changed: those alone are read and put in their places, and+ * every other row is left as it is. It used to read the whole book again for one card edited+ * on the phone — every card, every number — and compare each row. With a search typed, or a+ * read of the whole book already on its way, the book is read as the search has it instead:+ * that read decides who shows.+ */+ patch.current = (items: ItemChanges) => {+ const ids = [...items.added, ...items.changed];+ const next = () => {+ readDupes().catch(() => {});+ if (openGuid && (ids.includes(openGuid) || items.removed.includes(openGuid))) setCardRead((n) => n + 1);+ };+ if (search.trim() || reading.current > 0 || !loaded) {+ read(search).then(next, () => {});+ return;+ }+ const before = reads.current;+ (ids.length ? contactsApi.get(ids) : Promise.resolve([] as Contact[]))+ .then((found) => {+ // A whole read started since has every card as it is now.+ if (before !== reads.current) return;+ const fresh = new Map((Array.isArray(found) ? found : []).map((c) => [c.guid, c]));+ // Named but not found: gone since, as a removal is.+ const gone = new Set([...items.removed, ...ids.filter((id) => !fresh.has(id))]);+ setContacts((was) => {+ const placed = new Set<string>();+ const kept = was+ .filter((c) => !gone.has(c.guid))+ .map((c) => {+ const now = fresh.get(c.guid);+ if (!now) return c;+ placed.add(c.guid);+ return now;+ });+ const added = [...fresh.values()].filter((c) => !placed.has(c.guid));+ return added.length ? [...kept, ...added] : kept;+ });+ next();+ })+ .catch(() => read(search).then(next, () => {}));+ };+/** Everyone by id, for the duplicates view to draw from. */const byGuid = useMemo(() => new Map(contacts.map((c) => [c.guid, c])), [contacts]);@@ -482,7 +538,7 @@ export function ContactsView() {return () => {cancelled = true;};- }, [openGuid, due, tickDue]);+ }, [openGuid, due, tickDue, cardRead]);/*** Address edits: drawn at once, then sent. Turned down, the list goes back to what it was,@@ -627,25 +683,12 @@ export function ContactsView() {];};- /** Every write goes to Apple first, then the library is re-read. */- const write = useCallback(- async (run: () => Promise<void>) => {- setBusy(true);- setError(null);- try {- await run();- // A deleted contact leaves every list it was in, so the lists are read again too.- await Promise.all([read(search), readLists()]);- return true;- } catch (e) {- setError(messageOf(e));- return false;- } finally {- setBusy(false);- }- },- [read, readLists, search]- );+ /** After a write lands in the library: the book and the lists as it now holds them — a+ * deleted card leaves every list it was in — and who looks like whom. */+ const settleWrite = useCallback(() => {+ Promise.all([read(search), readLists()]).catch((e) => setError(messageOf(e)));+ readDupes().catch(() => {});+ }, [read, readLists, readDupes, search]);const saveDraft = useCallback(async () => {if (!draft) return;@@ -663,17 +706,40 @@ export function ContactsView() {if (edits.length) sendAddresses(saving.guid, base, edits, after);return;}+ // Shown at once as saved — the form put away, the card in the list and open — as every+ // write here is: the library takes it behind (it can wait out a pass storing, seconds on a+ // first sync of Photos), and Apple after that. Turned down, the card goes back to what it+ // was and the form comes back as it was being written, so nothing typed is lost.+ const was = draftBase.current;+ const stand: Contact = saving.guid ? saving : { ...saving, guid: `pending-card-${Date.now()}` };+ setContacts((all) => (saving.guid ? all.map((c) => (c.guid === saving.guid ? stand : c)) : [...all, stand]));+ setDraft(null);+ setPicked([]);+ setShowDupes(false);+ setOpenGuid(stand.guid);+ setError(null);if (edits.length && saving.guid) setAddresses({ guid: saving.guid, list: after });- const ok = await write(async () => {- guid = await api.contactSave(saving, saving.guid ? draftBase.current : null);- });- if (ok) {- setDraft(null);- setOpenGuid(guid);- readDupes().catch(() => {});- if (edits.length) sendAddresses(guid, base, edits, after);- } else if (edits.length && saving.guid) setAddresses({ guid: saving.guid, list: base });- }, [draft, draftAddresses, sendAddresses, write]);+ try {+ guid = await api.contactSave(saving, saving.guid ? was : null);+ } catch (e) {+ setContacts((all) =>+ saving.guid && was ? all.map((c) => (c.guid === saving.guid ? was : c)) : all.filter((c) => c.guid !== stand.guid),+ );+ if (edits.length && saving.guid) setAddresses({ guid: saving.guid, list: base });+ draftBase.current = was;+ setDraft(saving);+ setOpenGuid((cur) => (cur === stand.guid ? saving.guid || null : cur));+ setError(messageOf(e));+ return;+ }+ // The stand-in takes the id the card will keep, so the row and the selection stay put.+ if (!saving.guid) {+ setContacts((all) => all.map((c) => (c.guid === stand.guid ? { ...stand, guid } : c)));+ setOpenGuid((cur) => (cur === stand.guid ? guid : cur));+ }+ settleWrite();+ if (edits.length) sendAddresses(guid, base, edits, after);+ }, [draft, draftAddresses, sendAddresses, settleWrite]);/*** Deleting a person is not something to discover by accident. Inside a list, icloud.com@@ -687,12 +753,37 @@ export function ContactsView() {);};- const removeContact = useCallback(- async (guid: string) => {- if (await write(() => api.contactDelete(guid))) setDraft(null);+ /**+ * Cards deleted: gone from the list at once, then from the library and Apple behind. Any the+ * library turns down come back where they were, and say why.+ */+ const removeContacts = useCallback(+ async (guids: string[]) => {+ const going = new Set(guids);+ const gone = shownBook.current.filter((c) => going.has(c.guid));+ setContacts((all) => all.filter((c) => !going.has(c.guid)));+ setDraft((d) => (d && going.has(d.guid) ? null : d));+ setError(null);+ const kept: string[] = [];+ let why: unknown = null;+ for (const guid of guids) {+ try {+ await api.contactDelete(guid);+ } catch (e) {+ kept.push(guid);+ why = e;+ }+ }+ if (kept.length) {+ const back = gone.filter((c) => kept.includes(c.guid));+ setContacts((all) => [...all.filter((c) => !kept.includes(c.guid)), ...back]);+ setError(messageOf(why));+ }+ settleWrite();},- [write]+ [settleWrite]);+ const removeContact = useCallback((guid: string) => removeContacts([guid]), [removeContacts]);/** Editing a method in the draft, by position. */const editMethod = (index: number, patch: Partial<ContactMethod>) =>@@ -733,9 +824,7 @@ export function ContactsView() {});if (!sure) return;setPicked([]);- await write(async () => {- for (const c of people) await api.contactDelete(c.guid);- });+ await removeContacts(people.map((c) => c.guid));};/**@@ -834,10 +923,12 @@ export function ContactsView() {if (list && head) list.scrollTop = head.offsetTop;};- // The keys Contacts on the Mac answers (Ctrl in place of Command here): ⌘N a new card,- // ⌘F the search, the arrows walk the list — Shift with them widens the selection — Return- // edits the card, Delete deletes it, and Escape leaves a card being written unsaved.+ // The keys Contacts on the Mac answers (Ctrl in place of Command here): ⌘N a new card, ⇧⌘N+ // a new list, ⌘F the search, ⌘L edits the card, the arrows walk the list — Shift with them+ // widens the selection — Return edits the card, Delete deletes it, and Escape leaves a card+ // being written unsaved.const live = useActiveRef();+ const listsColumn = useRef<HTMLElement | null>(null);const keys = useRef<(e: KeyboardEvent) => void>(() => {});keys.current = (e: KeyboardEvent) => {if (!live.current || e.defaultPrevented) return;@@ -856,6 +947,19 @@ export function ContactsView() {}return;}+ if (command && e.shiftKey && k === "n") {+ e.preventDefault();+ if (draft) return;+ // Named in place in the lists column; where that has folded away, made as Untitled List.+ if (listsColumn.current?.offsetParent) setNaming("new");+ else void createList("Untitled List");+ return;+ }+ if (command && !e.shiftKey && k === "l") {+ e.preventDefault();+ if (!draft && open && !multi && !busy) edit(open);+ return;+ }if (command && !e.shiftKey && k === "f") {e.preventDefault();if (draft) return;@@ -926,7 +1030,7 @@ export function ContactsView() {return (// A contact being written is always what shows; it has its own Cancel.<div className={`contacts${detail || draft ? " is-detail" : ""}`}>- <aside className="contacts-lists" aria-label="Contact lists">+ <aside className="contacts-lists" aria-label="Contact lists" ref={listsColumn}><p className="side-heading">iCloud</p><ListRowname="All Contacts"@@ -1697,7 +1801,7 @@ const ContactRow = memo(function ContactRow({ contact, current, mine, draggable,onClick={(e) => actions.click(contact, e)}><Avatar contact={contact} />- <span className="contact-row-name">{displayName(contact)}</span>+ <span className="contact-row-name"><RowName contact={contact} /></span>{mine && <span className="contact-me" title="My Card">me</span>}<Waiting shown={waiting} /></button>@@ -1705,6 +1809,28 @@ const ContactRow = memo(function ContactRow({ contact, current, mine, draggable,);});+/**+ * A name in the list as Contacts on the Mac sets it: the part it is sorted by in bold — the+ * last name, or a company's name — the rest of it plain, so the order reads at a glance.+ */+function RowName({ contact: c }: { contact: Contact }) {+ const company = c.company?.trim();+ const last = c.lastName?.trim();+ if (!(c.isCompany && company) && last) {+ const lead = [c.firstName, c.middleName].filter((p) => p?.trim()).join(" ");+ return (+ <>+ {lead && `${lead} `}+ <b>{last}</b>+ </>+ );+ }+ const name = displayName(c);+ // A card with only a number has nothing it is sorted by: plain.+ const named = (c.isCompany && company) || c.firstName?.trim() || c.middleName?.trim() || company;+ return named ? <b>{name}</b> : <>{name}</>;+}+/** Text onto the clipboard; the older way where the newer one is refused. */async function copyText(text: string): Promise<boolean> {try {diff --git a/src/styles/app.css b/src/styles/app.cssindex 07c8dac..a47743d 100644--- a/src/styles/app.css+++ b/src/styles/app.css@@ -707,6 +707,7 @@.contact-rows.is-focused .contact-row[aria-selected="true"] .avatar:not(:has(img)) { background: rgba(255, 255, 255, 0.28); color: #fff; }.contact-row:focus-visible { outline: var(--focus-ring); outline-offset: -1px; }.contact-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.contact-row-name b { font-weight: 600; }/* Several picked: their faces fanned, the count, and what can be done to all of them. */.contact-many { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 48px; text-align: center; }.contact-many-faces { display: flex; }