feat(web): WS handlers for friend_request_sent + friend_request_relay_failed

Multi-tab sync: friend_request_sent appends the new outbound request to
socialStore (deduped by id+origin), no toast.

Async rollback: friend_request_relay_failed removes the row by id and
surfaces a warning toast with the target handle and reason. Wires the
client side of the rollback hook from T10.
This commit is contained in:
Jannis Braun
2026-04-25 22:29:45 +02:00
parent b28bf6646d
commit 9d3f75b33c
2 changed files with 33 additions and 0 deletions
+12
View File
@@ -57,6 +57,7 @@ interface SocialState {
removeFriend: (id: string) => Promise<void>;
searchUsers: (query: string) => Promise<TaggedUser[]>;
addIncomingRequest: (request: FriendRequest, origin: string) => void;
addOutboundRequest: (request: FriendRequest, origin: string) => void;
addFriendFromAccepted: (friend: Friend, requestId: string, origin: string) => void;
updateFriendPresence: (userId: string, status: string) => void;
updateFriendProfile: (user: User) => void;
@@ -343,6 +344,17 @@ export const useSocialStore = create<SocialState>((set, get) => ({
});
},
// Called from WS handler for multi-tab sync when this user creates an outbound request
addOutboundRequest: (request: FriendRequest, origin: string) => {
set((state) => {
const canonicalId = request.user?.homeUserId ?? request.user?.id;
if (canonicalId && state.requests.some(r => (r.user?.homeUserId ?? r.user?.id) === canonicalId)) {
return state;
}
return { requests: [...state.requests, { ...request, _instanceOrigin: origin }] };
});
},
// Called from WS handler when someone accepts your friend request
addFriendFromAccepted: (friend: Friend, requestId: string, origin: string) => {
set((state) => {