Add emitTyping method to chat store
This commit is contained in:
@@ -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: [],
|
||||
|
||||
Reference in New Issue
Block a user