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
+16
View File
@@ -64,6 +64,7 @@ interface ChatState {
onMarkUnread: (channelId: string, messageId: string) => void;
removeChannelStates: (channelIds: Set<string>) => void;
updateUserInMessages: (user: { id: string; [key: string]: any }) => void;
clearTypingForUser: (userId: string) => void;
}
/** Find which channel a message belongs to by scanning the message cache. */
@@ -727,4 +728,19 @@ export const useChatStore = create<ChatState>((set, get) => ({
return changed ? { messages: newMessages } : {};
});
},
clearTypingForUser: (userId: string) => {
set((state) => {
const newTyping = new Map(state.typingUsers);
let changed = false;
for (const [channelId, users] of newTyping) {
const filtered = users.filter(t => t.userId !== userId);
if (filtered.length !== users.length) {
newTyping.set(channelId, filtered);
changed = true;
}
}
return changed ? { typingUsers: newTyping } : state;
});
},
}));