From 6f615f4c32ceb65b22ee313811772014f27e6719 Mon Sep 17 00:00:00 2001 From: Max Hao Date: Wed, 17 Jun 2026 09:22:57 -0400 Subject: [PATCH] fix: fix directory fetching display names. --- stores/contact-store.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/stores/contact-store.ts b/stores/contact-store.ts index 27ee111a..0fa0fe24 100644 --- a/stores/contact-store.ts +++ b/stores/contact-store.ts @@ -289,7 +289,7 @@ export const useContactStore = create()( const email = p.email?.trim(); if (!email) continue; entries.push({ - name: p.name || email, + name: p.description || p.name || email, email, description: p.description ?? undefined, }); @@ -556,9 +556,20 @@ export const useContactStore = create()( for (const p of directoryPrincipals) { if (results.length >= 10) break; const addr = p.email.toLowerCase(); - if (seen.has(addr)) continue; - if (p.name.toLowerCase().includes(lower) || addr.includes(lower)) { - results.push({ name: p.name, email: p.email }); + if (seen.has(addr)) { + const betterName = p.description || p.name; + if (betterName && betterName !== p.email) { + const existing = results.find(r => r.email.toLowerCase() === addr); + if (existing && (!existing.name || existing.name === existing.email)) { + existing.name = betterName; + } + } + continue; + } + if (p.name.toLowerCase().includes(lower) || addr.includes(lower) || (p.description && p.description.toLowerCase().includes(lower))) { + const displayName = p.description || p.name; + const name = displayName !== p.email ? displayName : ''; + results.push({ name, email: p.email }); seen.add(addr); } }