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.

Contacts: Export vCard (one, two, a list or everyone, under Apple's file names), Import vCard, Make This My Card with "me" marked

Yashwanth Kamireddibb34ec6a3286
diff --git a/.uiverify/contacts-vcard.mjs b/.uiverify/contacts-vcard.mjs
new file mode 100644
index 0000000..90a5014
--- /dev/null
+++ b/.uiverify/contacts-vcard.mjs
@@ -0,0 +1,43 @@
+// vCards and My Card, as icloud.com offers them: a card or a whole list out to Downloads
+// under Apple's file names, a file brought in, and "me" beside this person's own card —
+// moved at once when another is made My Card.
+import { engine } 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 });
+const page = await ctx.newPage();
+await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
+await openScreen(page, "Contacts");
+await page.waitForTimeout(400);
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+const meRow = () => page.locator(".contact-row", { has: page.locator(".contact-me") }).locator(".contact-row-name").allInnerTexts();
+
+ok(JSON.stringify(await meRow()) === JSON.stringify(["Zoya Ahuja"]), "\"me\" marks this person's own card");
+await page.locator(".contact-row", { hasText: "Amma" }).click({ button: "right" });
+await page.getByRole("menuitem", { name: "Make This My Card" }).click();
+await page.waitForTimeout(150);
+ok(JSON.stringify(await meRow()) === JSON.stringify(["Amma"]), "Make This My Card moves it at once");
+
+await page.locator(".contact-row", { hasText: "Amma" }).click({ button: "right" });
+await page.getByRole("menuitem", { name: "Export vCard…" }).click();
+await page.waitForTimeout(200);
+let sent = await page.evaluate(() => window.__exports?.at(-1));
+ok(sent?.fileName === "Amma.vcf" && sent.guids.join() === "c2", `one card goes out under its name ${JSON.stringify(sent)}`);
+ok(/Saved to .*Amma\.vcf/.test(await page.locator(".drive-saved").innerText()), "and says where it went");
+
+await page.getByRole("button", { name: "More" }).click();
+await page.getByRole("menuitem", { name: "Export All Contacts…" }).click();
+await page.waitForTimeout(200);
+sent = await page.evaluate(() => window.__exports?.at(-1));
+ok(sent?.fileName === "iCloud vCards.vcf" && sent.guids.length === 4, `everyone goes out as iCloud vCards ${JSON.stringify(sent?.fileName)}`);
+
+await page.evaluate(() => { window.__pick = "/home/test/people.vcf"; });
+await page.getByRole("button", { name: "More" }).click();
+await page.getByRole("menuitem", { name: "Import vCard…" }).click();
+await page.waitForTimeout(300);
+ok((await page.evaluate(() => window.__imports?.at(-1)?.path)) === "/home/test/people.vcf", "a chosen file is imported");
+ok(/2 contacts imported/.test(await page.locator(".drive-saved").innerText()), "and the count is said");
+await b.close();
+process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjs
index 9cc626c..ccb82e9 100644
--- a/.uiverify/stub.mjs
+++ b/.uiverify/stub.mjs
@@ -235,6 +235,11 @@ 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;
+ case "contact_me": return window.__me ?? (contactsFixture ? "c1" : null);
+ case "contact_set_me": await new Promise((r) => setTimeout(r, 600)); window.__me = args.guid; return null;
+ case "contacts_export": (window.__exports ??= []).push(args); return `/home/test/Downloads/${args.fileName}`;
+ case "contacts_import": (window.__imports ??= []).push(args); return [2, 0];
+ case "plugin:dialog|open": return window.__pick ?? null;
case "contact_lists": return !contactsFixture ? [] : (window.__lists ??= [
{ guid: "L1", name: "Family", members: ["c2"], etag: "e1" },
]).map((l) => ({ ...l, members: [...l.members] }));
diff --git a/check.sh b/check.sh
index e108ffb..f37bf8d 100755
--- a/check.sh
+++ b/check.sh
@@ -63,6 +63,7 @@ step "reminder keys" node .uiverify/reminders-keys.mjs
step "contacts order" node .uiverify/contacts-order.mjs
step "contacts lists" node .uiverify/contacts-lists.mjs
step "drive keys" node .uiverify/drive-keys.mjs
+step "contacts vcard" node .uiverify/contacts-vcard.mjs
step "calendar alerts" node .uiverify/calendar-alerts.mjs
step "calendar repeat" node .uiverify/calendar-repeat.mjs
step "reminder add/done" node .uiverify/reminders-add-done.mjs
diff --git a/crates/quince-icloud/src/contacts.rs b/crates/quince-icloud/src/contacts.rs
index b514bf8..471ff38 100644
--- a/crates/quince-icloud/src/contacts.rs
+++ b/crates/quince-icloud/src/contacts.rs
@@ -201,6 +201,7 @@ pub async fn fetch_book_with_tokens(
AddressBook {
contacts: parse(&body),
lists: parse_lists(&body),
+ me: me_card(&body),
},
Tokens {
sync: token("syncToken")?,
@@ -470,8 +471,13 @@ pub struct ContactList {
pub struct AddressBook {
pub contacts: Vec<quince_core::contacts::Contact>,
pub lists: Vec<ContactList>,
+ /// The card that is this person's own, if they have said.
+ pub me: Option<String>,
}
+/// Where the my-card id is kept between passes.
+pub const ME_KEY: &str = "contacts.me";
+
/// Where the lists are kept between passes. They are few and small, so beside the library's
/// other settings rather than in a table of their own.
pub const LISTS_KEY: &str = "contacts.lists";
@@ -663,6 +669,152 @@ pub async fn delete_list(
Ok(())
}
+/// A plain-text call to Contacts with the address book's tokens, as icloud.com makes its
+/// export, import and my-card calls. Answers with Apple's reply as text.
+async fn co_text(
+ http: &reqwest::Client,
+ root: &str,
+ params: Vec<(String, String)>,
+ tokens: &Tokens,
+ method: reqwest::Method,
+ path: &str,
+ body: String,
+) -> Result<String> {
+ let mut query = params;
+ query.push(("clientVersion".into(), "2.1".into()));
+ query.push(("locale".into(), "en_US".into()));
+ query.push(("order".into(), "last,first".into()));
+ query.push(("prefToken".into(), tokens.pref.clone()));
+ query.push(("syncToken".into(), tokens.sync.clone()));
+ let url = format!("{}/{path}", root.trim_end_matches('/'));
+ let response = http
+ .request(method, url)
+ .query(&query)
+ .header("content-type", "text/plain")
+ .body(body)
+ .send()
+ .await?;
+ let status = response.status();
+ let text = response.text().await.unwrap_or_default();
+ if status.as_u16() == 450 {
+ return Err(Error::ReauthRequired);
+ }
+ if status.as_u16() == 412 || status.as_u16() == 409 {
+ return Err(Error::Conflict);
+ }
+ if !status.is_success() {
+ return Err(Error::Protocol(format!(
+ "contacts returned {status}: {}",
+ text.chars().take(200).collect::<String>()
+ )));
+ }
+ Ok(text)
+}
+
+/// These people as one vCard file, written by Apple — every field it holds, photos too.
+pub async fn export_vcards(
+ http: &reqwest::Client,
+ root: &str,
+ params: Vec<(String, String)>,
+ tokens: &Tokens,
+ ids: &[String],
+ file_name: &str,
+) -> Result<String> {
+ let body = serde_json::json!({ "contactIdsToExport": ids, "exportFileName": file_name });
+ let text = co_text(
+ http,
+ root,
+ params,
+ tokens,
+ reqwest::Method::POST,
+ "co/export/",
+ body.to_string(),
+ )
+ .await?;
+ if !text.trim_start().starts_with("BEGIN:VCARD") {
+ return Err(Error::Protocol(
+ "Contacts did not send back a vCard.".into(),
+ ));
+ }
+ Ok(text)
+}
+
+/// Add the people in a vCard file to Contacts. Answers with the ids Apple gave them, and
+/// how many cards it could not read.
+pub async fn import_vcards(
+ http: &reqwest::Client,
+ root: &str,
+ params: Vec<(String, String)>,
+ tokens: &Tokens,
+ vcard: &str,
+) -> Result<(Vec<String>, usize)> {
+ // Apple's own ceiling for an import, checked here so the refusal says why.
+ if vcard.len() > 10 * 1024 * 1024 {
+ return Err(Error::Refused(
+ "That file is larger than the 10 MB Contacts takes at once.".into(),
+ ));
+ }
+ if !vcard.contains("BEGIN:VCARD") {
+ return Err(Error::Refused("That file holds no contacts.".into()));
+ }
+ let text = co_text(
+ http,
+ root,
+ params,
+ tokens,
+ reqwest::Method::POST,
+ "co/import/",
+ vcard.to_string(),
+ )
+ .await?;
+ let body: Value = serde_json::from_str(&text).unwrap_or(Value::Null);
+ let ids = body
+ .get("importedContactIds")
+ .and_then(Value::as_array)
+ .map(|a| {
+ a.iter()
+ .filter_map(Value::as_str)
+ .map(ToString::to_string)
+ .collect()
+ })
+ .unwrap_or_default();
+ let failed = body
+ .get("errors")
+ .and_then(Value::as_array)
+ .map_or(0, Vec::len);
+ Ok((ids, failed))
+}
+
+/// Say which card is this person's own — "My Card" on every device.
+pub async fn set_me_card(
+ http: &reqwest::Client,
+ root: &str,
+ params: Vec<(String, String)>,
+ tokens: &Tokens,
+ id: &str,
+) -> Result<()> {
+ let body = serde_json::json!({ "meCardId": id });
+ co_text(
+ http,
+ root,
+ params,
+ tokens,
+ reqwest::Method::PUT,
+ "co/mecardid",
+ body.to_string(),
+ )
+ .await?;
+ Ok(())
+}
+
+/// Which card is this person's own, as `/co/startup` says.
+pub fn me_card(body: &Value) -> Option<String> {
+ body.get("meCardId")
+ .and_then(Value::as_str)
+ .filter(|s| !s.is_empty())
+ .map(ToString::to_string)
+}
+
/// Fetch the address book and reconcile it into the library.
pub async fn sync(
http: &reqwest::Client,
@@ -685,6 +837,7 @@ pub async fn fetch(
Ok(AddressBook {
contacts: parse(&body),
lists: parse_lists(&body),
+ me: me_card(&body),
})
}
@@ -729,6 +882,7 @@ pub fn apply(library: &mut quince_core::Library, book: AddressBook) -> Result<us
LISTS_KEY,
&serde_json::to_string(&book.lists).unwrap_or_else(|_| "[]".into()),
)?;
+ library.set_state(ME_KEY, book.me.as_deref().unwrap_or(""))?;
library.mark_synced("contacts", None)?;
Ok(book.contacts.len())
}
diff --git a/probe/examples/contacts_vcard.rs b/probe/examples/contacts_vcard.rs
new file mode 100644
index 0000000..cfb6fbe
--- /dev/null
+++ b/probe/examples/contacts_vcard.rs
@@ -0,0 +1,50 @@
+//! Live, throwaway contact only: a vCard for "Quince vCard test" imported, exported back,
+//! then deleted. The my-card id is read, never changed.
+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("contacts")
+ .ok_or_else(|| anyhow!("no contacts"))?;
+ let (http, p) = (client.http().clone(), client.service_params());
+ use quince_icloud::contacts as c;
+ let (_, tokens) = c::fetch_with_tokens(&http, &root, p.clone()).await?;
+ let card = "BEGIN:VCARD\r\nVERSION:3.0\r\nN:test;Quince vCard;;;\r\nFN:Quince vCard test\r\nTEL;type=CELL:+1 555 0100\r\nEND:VCARD\r\n";
+ let (ids, failed) = c::import_vcards(&http, &root, p.clone(), &tokens, card).await?;
+ println!("imported {ids:?}, {failed} failed");
+ let id = ids
+ .first()
+ .ok_or_else(|| anyhow!("nothing imported"))?
+ .clone();
+ let (_, tokens) = c::fetch_with_tokens(&http, &root, p.clone()).await?;
+ let out = c::export_vcards(
+ &http,
+ &root,
+ p.clone(),
+ &tokens,
+ std::slice::from_ref(&id),
+ "Quince vCard test.vcf",
+ )
+ .await?;
+ println!(
+ "exported {} bytes; has name: {}; has phone: {}",
+ out.len(),
+ out.contains("Quince vCard"),
+ out.contains("555")
+ );
+ let (people, tokens) = c::fetch_with_tokens(&http, &root, p.clone()).await?;
+ let mine = people
+ .iter()
+ .find(|x| x.guid == id)
+ .ok_or_else(|| anyhow!("not in the book"))?;
+ c::delete(&http, &root, p.clone(), &tokens, mine).await?;
+ let (people, _) = c::fetch_with_tokens(&http, &root, p.clone()).await?;
+ println!("deleted: {}", !people.iter().any(|x| x.guid == id));
+ Ok(())
+}
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 823855c..4ecddbb 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -1558,6 +1558,110 @@ async fn contact_delete(
resync_contacts(&http, &root, params, &data).await
}
+/// A path in `dir` for `name` that holds nothing yet: a number goes on the end rather than
+/// writing over a file already there — the rule a browser follows.
+fn free_path(dir: &std::path::Path, name: &str) -> std::path::PathBuf {
+ let (stem, ext) = name.rsplit_once('.').map_or((name, ""), |(s, e)| (s, e));
+ let mut path = dir.join(name);
+ let mut suffix = 1;
+ while path.exists() {
+ path = dir.join(if ext.is_empty() {
+ format!("{stem} {suffix}")
+ } else {
+ format!("{stem} {suffix}.{ext}")
+ });
+ suffix += 1;
+ }
+ path
+}
+
+/// These people as a vCard file in Downloads, written by Apple. Returns where it went.
+#[tauri::command]
+async fn contacts_export(
+ guids: Vec<String>,
+ file_name: String,
+ app: tauri::AppHandle,
+ auth: State<'_, Auth>,
+) -> UiResult<String> {
+ if guids.is_empty() {
+ return Err("Choose someone to export.".into());
+ }
+ let (http, root, params) = contacts_context(&auth).await?;
+ let (_, tokens) = quince_icloud::contacts::fetch_with_tokens(&http, &root, params.clone())
+ .await
+ .map_err(|e| e.to_string())?;
+ let vcard =
+ quince_icloud::contacts::export_vcards(&http, &root, params, &tokens, &guids, &file_name)
+ .await
+ .map_err(|e| e.to_string())?;
+ let downloads = app
+ .path()
+ .download_dir()
+ .map_err(|_| "Couldn't find your Downloads folder.".to_string())?;
+ // A name fit for a file: no folders smuggled in, never empty.
+ let clean: String = file_name
+ .chars()
+ .filter(|c| !matches!(c, '/' | '\\' | '\0'))
+ .collect();
+ let clean = if clean.trim().trim_end_matches(".vcf").is_empty() {
+ "iCloud vCards.vcf".into()
+ } else {
+ clean
+ };
+ let path = free_path(&downloads, &clean);
+ std::fs::write(&path, vcard).map_err(|e| format!("Couldn't save the vCard: {e}"))?;
+ Ok(path.to_string_lossy().into_owned())
+}
+
+/// Add everyone in a vCard file to Contacts. Answers how many came in and how many could not.
+#[tauri::command]
+async fn contacts_import(
+ path: String,
+ auth: State<'_, Auth>,
+ data: State<'_, Data>,
+) -> UiResult<(usize, usize)> {
+ let text =
+ std::fs::read_to_string(&path).map_err(|e| format!("Couldn't read that file: {e}"))?;
+ let (http, root, params) = contacts_context(&auth).await?;
+ let (_, tokens) = quince_icloud::contacts::fetch_with_tokens(&http, &root, params.clone())
+ .await
+ .map_err(|e| e.to_string())?;
+ let (ids, failed) =
+ quince_icloud::contacts::import_vcards(&http, &root, params.clone(), &tokens, &text)
+ .await
+ .map_err(|e| e.to_string())?;
+ resync_contacts(&http, &root, params, &data).await?;
+ Ok((ids.len(), failed))
+}
+
+/// The card that is this person's own, as the last pass stored it.
+#[tauri::command]
+async fn contact_me(data: State<'_, Data>) -> UiResult<Option<String>> {
+ let library = data.0.lock().await;
+ Ok(library
+ .state(quince_icloud::contacts::ME_KEY)
+ .ok()
+ .flatten()
+ .filter(|s| !s.is_empty()))
+}
+
+/// Make this card "My Card", on every device.
+#[tauri::command]
+async fn contact_set_me(
+ guid: String,
+ auth: State<'_, Auth>,
+ data: State<'_, Data>,
+) -> UiResult<()> {
+ let (http, root, params) = contacts_context(&auth).await?;
+ let (_, tokens) = quince_icloud::contacts::fetch_with_tokens(&http, &root, params.clone())
+ .await
+ .map_err(|e| e.to_string())?;
+ quince_icloud::contacts::set_me_card(&http, &root, params.clone(), &tokens, &guid)
+ .await
+ .map_err(|e| e.to_string())?;
+ resync_contacts(&http, &root, params, &data).await
+}
+
/// The address book, optionally filtered by name or by any stored number or address.
#[tauri::command]
async fn contacts_list(search: Option<String>, data: State<'_, Data>) -> UiResult<Vec<Contact>> {
@@ -2640,6 +2744,10 @@ fn main() {
contacts_list,
contact_save,
contact_lists,
+ contacts_export,
+ contacts_import,
+ contact_me,
+ contact_set_me,
contact_list_write,
contact_delete,
drive_sync_folder,
diff --git a/src/lib/ipc.ts b/src/lib/ipc.ts
index 6c3d8bf..b8d6cc2 100644
--- a/src/lib/ipc.ts
+++ b/src/lib/ipc.ts
@@ -159,6 +159,13 @@ export const api = {
contactSave: (contact: Contact) => invoke<string>("contact_save", { contact }),
contactDelete: (guid: string) => invoke<void>("contact_delete", { guid }),
contactsList: (search: string | null) => invoke<Contact[]>("contacts_list", { search }),
+ /** These people as a vCard file in Downloads, written by Apple. Returns the path. */
+ contactsExport: (guids: string[], fileName: string) => invoke<string>("contacts_export", { guids, fileName }),
+ /** Everyone in a vCard file, added to Contacts. Returns [added, could not be read]. */
+ contactsImport: (path: string) => invoke<[number, number]>("contacts_import", { path }),
+ /** The card that is this person's own, if they have said. */
+ contactMe: () => invoke<string | null>("contact_me"),
+ contactSetMe: (guid: string) => invoke<void>("contact_set_me", { guid }),
/** Contacts' lists — Apple's groups — in the order Apple keeps them. */
contactLists: () => invoke<ContactList[]>("contact_lists"),
/**
diff --git a/src/screens/ContactsView.tsx b/src/screens/ContactsView.tsx
index 504cd16..9a16969 100644
--- a/src/screens/ContactsView.tsx
+++ b/src/screens/ContactsView.tsx
@@ -14,6 +14,7 @@ import { useSync } from "../lib/sync";
import { Picker } from "../components/Picker";
import { RowMenu, type MenuEntry } from "../components/RowMenu";
import { Portal } from "../components/Portal";
+import { open as openFileDialog } from "@tauri-apps/plugin-dialog";
/** The sidebar row that is every contact rather than a list. */
const ALL = "";
@@ -108,6 +109,11 @@ 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);
+ /** The card that is this person's own. */
+ const [me, setMe] = useState<string | null>(null);
+ /** A moment's word that something finished — a file saved, cards brought in. */
+ const [done, setDone] = useState<string | null>(null);
+ const [moreMenu, setMoreMenu] = useState<MenuAt | 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);
@@ -139,9 +145,55 @@ export function ContactsView() {
}, [read, search, revision]);
const readLists = useCallback(async () => {
- const found = await api.contactLists();
+ const [found, mine] = await Promise.all([api.contactLists(), api.contactMe()]);
setLists(Array.isArray(found) ? found : []);
+ setMe(typeof mine === "string" ? mine : null);
}, []);
+ // The word is a moment, not something that lingers over the next thing done.
+ useEffect(() => {
+ if (!done) return undefined;
+ const timer = window.setTimeout(() => setDone(null), 4000);
+ return () => window.clearTimeout(timer);
+ }, [done]);
+
+ /** People out as a vCard, named as icloud.com names the file. */
+ const exportCards = async (people: Contact[], label?: string) => {
+ if (people.length === 0) return;
+ const name =
+ people.length === 1 ? displayName(people[0])
+ : people.length === 2 ? `${displayName(people[0])} and ${displayName(people[1])}`
+ : label ?? "iCloud vCards";
+ try {
+ const path = await api.contactsExport(people.map((c) => c.guid), `${name}.vcf`);
+ setDone(`Saved to ${path}`);
+ } catch (e) {
+ setError(messageOf(e));
+ }
+ };
+ const importCards = async () => {
+ try {
+ const chosen = await openFileDialog({ multiple: false, title: "Import vCard", filters: [{ name: "vCard", extensions: ["vcf", "vcard"] }] });
+ if (!chosen || Array.isArray(chosen)) return;
+ setBusy(true);
+ const [added, failed] = await api.contactsImport(chosen);
+ await Promise.all([read(search), readLists()]);
+ setDone(`${added} ${added === 1 ? "contact" : "contacts"} imported${failed ? `, ${failed} could not be read` : ""}.`);
+ } catch (e) {
+ setError(messageOf(e));
+ } finally {
+ setBusy(false);
+ }
+ };
+ const makeMine = async (c: Contact) => {
+ const was = me;
+ setMe(c.guid);
+ try {
+ await api.contactSetMe(c.guid);
+ } catch (e) {
+ setMe(was);
+ setError(messageOf(e));
+ }
+ };
useEffect(() => {
readLists().catch((e) => setError(messageOf(e)));
}, [readLists, revision]);
@@ -246,6 +298,8 @@ export function ContactsView() {
...(openList ? [{ label: `Remove from \u201c${openList.name}\u201d`, run: () => removeFromList(openList, [c.guid]) }] : []),
null,
{ label: "Edit Contact", run: () => { setOpenGuid(c.guid); setDraft({ ...c }); } },
+ ...(me === c.guid ? [] : [{ label: "Make This My Card", run: () => void makeMine(c) }]),
+ { label: "Export vCard\u2026", run: () => void exportCards([c]) },
{ label: "Delete Contact\u2026", danger: true, run: () => {
askDelete(c);
} },
@@ -389,6 +443,19 @@ export function ContactsView() {
<button className="quiet" disabled={busy} onClick={() => setDraft(blank())}>
New contact
</button>
+ <button
+ className="quiet"
+ aria-label="More"
+ aria-haspopup="menu"
+ title="More"
+ disabled={busy}
+ onClick={(e) => {
+ const r = e.currentTarget.getBoundingClientRect();
+ setMoreMenu({ x: r.left, y: r.bottom + 4, alignRight: false });
+ }}
+ >
+ •••
+ </button>
</div>
</header>
@@ -412,6 +479,17 @@ export function ContactsView() {
</div>
{error && <Notice message={error} onDismiss={() => setError(null)} />}
+ {done && <p className="drive-saved" role="status">{done}</p>}
+ {moreMenu && (
+ <RowMenu
+ at={moreMenu}
+ onClose={() => setMoreMenu(null)}
+ entries={[
+ { label: "Import vCard\u2026", run: () => void importCards() },
+ { label: openList ? `Export \u201c${openList.name}\u201d\u2026` : "Export All Contacts\u2026", run: () => void exportCards(sortedContacts(shown), openList?.name) },
+ ]}
+ />
+ )}
<ul className="contact-rows">
{sortedContacts(shown).map((contact, i, all) => (
@@ -444,6 +522,7 @@ export function ContactsView() {
>
<Avatar contact={contact} />
<span className="contact-row-name">{displayName(contact)}</span>
+ {me === contact.guid && <span className="contact-me" title="My Card">me</span>}
</button>
</li>
</Fragment>
@@ -658,6 +737,7 @@ export function ContactsView() {
{open.company && !open.isCompany && (
<p className="contact-company">{open.company}</p>
)}
+ {me === open.guid && <p className="contact-company">My Card</p>}
</div>
</div>
diff --git a/src/styles/app.css b/src/styles/app.css
index 5e7a138..1ab5f69 100644
--- a/src/styles/app.css
+++ b/src/styles/app.css
@@ -872,6 +872,9 @@
.contact-rows:focus-within .contact-row[aria-current="true"] .avatar:not(:has(img)) { background: rgba(255, 255, 255, 0.28); color: #fff; }
.contact-row:focus-visible { outline: 3px solid var(--gold-ring); outline-offset: -1px; }
.contact-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+/* "me" beside this person's own card, as Contacts marks it. */
+.contact-me { margin-left: auto; color: var(--text-3); font-size: var(--t-11); }
+.contact-rows:focus-within .contact-row[aria-current="true"] .contact-me { color: rgba(255, 255, 255, 0.82); }
.avatar {
width: 26px;