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:
@@ -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;
|
||||
});
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user