Browse Source

FIX | fix chat title update

merge-requests/131/head
Yevhen Romanenko 2 years ago
parent
commit
a24f3f69fe
  1. 11
      src/containers/Chats/hooks/use-chat-details.hook.ts

11
src/containers/Chats/hooks/use-chat-details.hook.ts

@ -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,

Loading…
Cancel
Save