fix: load social data on WS ready and use federation-safe canonical matching for friend button state

Friends/requests were only loaded when FriendsPage or ActivityPanel rendered,
so profile modals in space views always showed "Add Friend" even for existing
friends. Now loadFriends/loadRequests fire on every WS ready event.

Also adds canonicalUserMatch() with cascading ID/homeUserId/username+instance
fallback, replacing fragile homeUserId-only matching in getFriendshipStatus.
This commit is contained in:
Jannis Braun
2026-03-10 19:56:13 +01:00
parent 274f5a710e
commit d7449bdf42
3 changed files with 148 additions and 27 deletions
+9
View File
@@ -263,6 +263,15 @@ function handleEvent(origin: string, event: ServerEvent): void {
}
}
}
// Load social data so profile modals show correct friendship state.
// Runs on each ready (home + remote) — loadFriends/loadRequests fan out
// across all connected instances and replace the arrays (idempotent).
{
const { loadFriends, loadRequests } = useSocialStore.getState();
loadFriends();
loadRequests();
}
break;
case 'message_created':