feat: add store methods for deleted user cleanup

Add removeRequestsForUser (socialStore), removeUser (discoverStore), and
clearTypingForUser (chatStore) to support isDeleted cleanup in the
user_updated WS handler.
This commit is contained in:
Jannis Braun
2026-04-03 04:22:03 +02:00
parent 9d4b759cb4
commit 0f381c75db
3 changed files with 32 additions and 0 deletions
+8
View File
@@ -56,6 +56,7 @@ interface SocialState {
updateFriendProfile: (user: User) => void;
removeFriendLocally: (userId: string, origin: string) => void;
removeRequestById: (requestId: string, origin: string) => void;
removeRequestsForUser: (userId: string) => void;
reset: () => void;
}
@@ -326,6 +327,13 @@ export const useSocialStore = create<SocialState>((set, get) => ({
}));
},
// Called when a user is deleted — remove all pending requests involving them
removeRequestsForUser: (userId: string) => {
set((state) => ({
requests: state.requests.filter(r => r.fromId !== userId && r.toId !== userId),
}));
},
// Called from WS handler on presence_update to keep friend status live
updateFriendPresence: (userId: string, status: string) => {
set((state) => ({