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: Export All Contacts exports everyone while a search is typed
Yashwanth Kamireddia73d5e2ce146
diff --git a/.uiverify/contacts-export-all.mjs b/.uiverify/contacts-export-all.mjsnew file mode 100644index 0000000..c1fb7ee--- /dev/null+++ b/.uiverify/contacts-export-all.mjs@@ -0,0 +1,31 @@+// Export All Contacts exports everyone, whatever is typed in the search: with a search open it+// exported only the people that search had found, under the name of the whole book.+//+// URL=http://localhost:4203 ENGINE=webkit node .uiverify/contacts-export-all.mjs+import { engine, engineName } from "./engine.mjs";+import { SERVICES, installStub, openScreen } from "./stub.mjs";+const BASE = process.env.URL ?? "http://localhost:4173";+const b = await engine.launch();+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${engineName} ${m}`); if (!p) failures++; };+const ctx = await b.newContext({ viewport: { width: 1200, height: 800 } });+await ctx.addInitScript(() => { window.__contactsSearch = true; });+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, contactsFixture: true });+const page = await ctx.newPage();+page.on("pageerror", (e) => ok(false, `page error: ${e.message}`));+await page.goto(BASE, { waitUntil: "networkidle" });+await openScreen(page, "Contacts");+await page.waitForTimeout(400);+const everyone = await page.locator(".contact-rows > li .contact-row, .contact-rows > li button").count();+await page.getByRole("searchbox", { name: "Search contacts" }).or(page.locator(".contacts-search")).first().fill("zoya");+await page.waitForTimeout(400);+const rows = (await page.locator(".contact-rows > li").allInnerTexts()).filter((t) => t.trim().length > 1);+ok(rows.length === 1, `the search shows its one match ${JSON.stringify(rows)}`);+await page.getByRole("button", { name: /^More/ }).first().click();+await page.getByRole("menuitem", { name: "Export All Contacts" }).click();+await page.waitForTimeout(300);+const sent = await page.evaluate(() => window.__exports ?? []);+ok(sent.length === 1 && sent[0].guids.length === 4, `every contact is exported, not only the match ${JSON.stringify(sent.map((e) => e.guids))} (${everyone} rows)`);+await b.close();+console.log(failures ? `\n${failures} FAILED` : "\nall passed");+process.exit(failures ? 1 : 0);diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjsindex 74a4658..0eb4ea8 100644--- a/.uiverify/stub.mjs+++ b/.uiverify/stub.mjs@@ -826,7 +826,12 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note}case "contact_save": (window.__contactSaves ??= []).push(args); return "C-new";case "contact_delete": (window.__contactDeletes ??= []).push(args); return null;- case "contacts_list": return !contactsFixture ? [] : contactList.slice();+ case "contacts_list": {+ if (!contactsFixture) return [];+ // Opt-in: a search answered with its matches only, as the library answers it.+ const q = window.__contactsSearch && args?.search ? String(args.search).toLowerCase() : "";+ return q ? contactList.filter((c) => [c.firstName, c.lastName, c.company, ...c.methods.map((m) => m.value)].join(" ").toLowerCase().includes(q)) : contactList.slice();+ }// Duplicates as contacts_merge.rs finds them, on the fixture: a shared number (its// last ten digits), a shared email, or the same name.case "contacts_duplicates": {diff --git a/src/screens/ContactsView.tsx b/src/screens/ContactsView.tsxindex 80d7109..7ffeeb4 100644--- a/src/screens/ContactsView.tsx+++ b/src/screens/ContactsView.tsx@@ -344,6 +344,24 @@ export function ContactsView() {setError(messageOf(e));}};+ /**+ * Export All Contacts, or the open list: everyone in it, whatever the search shows. With a+ * search typed it exported only the people found, under the whole book's name.+ */+ const exportWhole = async () => {+ let people = sorted;+ if (search.trim()) {+ try {+ const all = await api.contactsList(null);+ const members = list === ALL ? null : new Set((lists.find((l) => l.guid === list)?.members ?? []).map((m) => m.toUpperCase()));+ people = sortedContacts(members ? all.filter((c) => members.has(c.guid.toUpperCase())) : all);+ } catch (e) {+ setError(messageOf(e));+ return;+ }+ }+ await exportCards(people, openList?.name);+ };const importCards = async () => {try {// Any number of files at once, vCard or a CSV exported from Google Contacts or Outlook.@@ -1010,7 +1028,7 @@ export function ContactsView() {onClose={() => setMoreMenu(null)}entries={[{ label: "Import Contacts", run: () => void importCards() },- { label: openList ? `Export \u201c${openList.name}\u201d` : "Export All Contacts", run: () => void exportCards(sorted, openList?.name) },+ { label: openList ? `Export \u201c${openList.name}\u201d` : "Export All Contacts", run: () => void exportWhole() },]}/>)}