From f0e72dc2570d1fa9d691ea562fadff701486a688 Mon Sep 17 00:00:00 2001 From: Jannis Braun <151788261+TheZwiss@users.noreply.github.com> Date: Wed, 25 Mar 2026 02:19:51 +0100 Subject: [PATCH] fix(social): deduplicate federated search results by canonical identity Replicated profiles on remote instances have different local IDs but share the same homeUserId as the native profile. Use homeUserId ?? id as the dedup key so the same person only appears once. Home instance is queried first, so the native profile (with clean username) wins. --- packages/web/src/stores/socialStore.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/web/src/stores/socialStore.ts b/packages/web/src/stores/socialStore.ts index cca77eaf..b38c4075 100644 --- a/packages/web/src/stores/socialStore.ts +++ b/packages/web/src/stores/socialStore.ts @@ -261,9 +261,12 @@ export const useSocialStore = create((set, get) => ({ if (result.status !== 'fulfilled') return; const origin = searches[i]!.origin; for (const user of result.value) { - const dedupeKey = `${origin ?? ''}:${user.id}`; - if (seen.has(dedupeKey)) continue; - seen.add(dedupeKey); + // Deduplicate by canonical identity: replicated profiles share + // the same homeUserId as the native profile's id, so collapse them. + // Prefer the first seen (home instance is queried first → native wins). + const canonicalId = user.homeUserId ?? user.id; + if (seen.has(canonicalId)) continue; + seen.add(canonicalId); if (origin) normalizeUserAssets(user, origin); allUsers.push({ ...user, _instanceOrigin: origin }); }