Add emitTyping method to chat store

This commit is contained in:
2026-03-11 21:34:48 -07:00
parent 4c9568e8da
commit be2fd137ba
+7
View File
@@ -20,6 +20,7 @@ interface ChatState {
openConversation: (friendId: string) => Promise<void>;
loadMoreMessages: () => Promise<void>;
sendMessage: (friendId: string, content: string) => void;
emitTyping: (friendId: string) => void;
clearChat: () => void;
}
@@ -140,6 +141,12 @@ export const useChatStore = create<ChatState>((set, get) => ({
socket.emit('send-message', { recipientId: friendId, content });
},
emitTyping: (friendId: string) => {
const { socket } = get();
if (!socket) return;
socket.emit('typing', { recipientId: friendId });
},
clearChat: () => {
set({
messages: [],