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.
This commit is contained in:
Jannis Braun
2026-03-25 02:19:51 +01:00
parent d59ec4abf2
commit f0e72dc257
+6 -3
View File
@@ -261,9 +261,12 @@ export const useSocialStore = create<SocialState>((set, get) => ({
if (result.status !== 'fulfilled') return; if (result.status !== 'fulfilled') return;
const origin = searches[i]!.origin; const origin = searches[i]!.origin;
for (const user of result.value) { for (const user of result.value) {
const dedupeKey = `${origin ?? ''}:${user.id}`; // Deduplicate by canonical identity: replicated profiles share
if (seen.has(dedupeKey)) continue; // the same homeUserId as the native profile's id, so collapse them.
seen.add(dedupeKey); // 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); if (origin) normalizeUserAssets(user, origin);
allUsers.push({ ...user, _instanceOrigin: origin }); allUsers.push({ ...user, _instanceOrigin: origin });
} }