|
|
|
@ -73,11 +73,22 @@ export const useChatDetails = (chatId: number) => {
@@ -73,11 +73,22 @@ export const useChatDetails = (chatId: number) => {
|
|
|
|
|
const onDeleteChatHeaderData = () => { |
|
|
|
|
setHeaderChatInfo(headerChatInfoInitialState); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const updateChatData = (id: number) => { |
|
|
|
|
if (id !== chatId) return; |
|
|
|
|
fetchDetails(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const onEditChat = (data: { chatId: number }) => { |
|
|
|
|
updateChatData(data?.chatId); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// APP EVENTS LISTENERS //
|
|
|
|
|
|
|
|
|
|
useEventsListener("onDeleteChatForMe", onDeleteChatHeaderData); |
|
|
|
|
|
|
|
|
|
useSocketListener("chat/delete-chat", onDeleteChatHeaderData, [chatId]); |
|
|
|
|
useSocketListener("chat/edit-chat", onEditChat, [chatId]); |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
chatDetails, |
|
|
|
|