diff --git a/src/stores/chat-store.ts b/src/stores/chat-store.ts index c43b47c..67e0542 100644 --- a/src/stores/chat-store.ts +++ b/src/stores/chat-store.ts @@ -20,6 +20,7 @@ interface ChatState { openConversation: (friendId: string) => Promise; loadMoreMessages: () => Promise; sendMessage: (friendId: string, content: string) => void; + emitTyping: (friendId: string) => void; clearChat: () => void; } @@ -140,6 +141,12 @@ export const useChatStore = create((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: [],