|
|
|
@ -94,6 +94,20 @@ export const useChatDetails = (chatId: number) => {
@@ -94,6 +94,20 @@ export const useChatDetails = (chatId: number) => {
|
|
|
|
|
history.push(`/chats`); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const onDeleteChatForMe = () => { |
|
|
|
|
setHeaderChatInfo(headerChatInfoInitialState); |
|
|
|
|
|
|
|
|
|
simpleDispatch(new UnselectChat()); |
|
|
|
|
history.push(`/chats`); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const onDeleteChatForAll = () => { |
|
|
|
|
setHeaderChatInfo(headerChatInfoInitialState); |
|
|
|
|
|
|
|
|
|
simpleDispatch(new UnselectChat()); |
|
|
|
|
history.push(`/chats`); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const updateChatData = (id: number) => { |
|
|
|
|
if (id !== chatId) return; |
|
|
|
|
fetchDetails(); |
|
|
|
@ -112,16 +126,17 @@ export const useChatDetails = (chatId: number) => {
@@ -112,16 +126,17 @@ export const useChatDetails = (chatId: number) => {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const onChangeChatRole = (data: { chatId: number }) => { |
|
|
|
|
console.log("changed role"); |
|
|
|
|
updateChatData(data?.chatId); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// APP EVENTS LISTENERS //
|
|
|
|
|
|
|
|
|
|
useEventsListener("onDeleteChatForMe", onDeleteChatHeaderData); |
|
|
|
|
useEventsListener("onDeleteChatForMe", onDeleteChatForMe); |
|
|
|
|
useEventsListener("onClearAllChats", onClearAllChats); |
|
|
|
|
useEventsListener("onDeleteAllChats", onDeleteAllChats); |
|
|
|
|
|
|
|
|
|
useSocketListener("chat/delete-chat", onDeleteChatHeaderData, [chatId]); |
|
|
|
|
useSocketListener("chat/delete-chat", onDeleteChatForAll, [chatId]); |
|
|
|
|
useSocketListener("chat/edit-chat", onEditChat, [chatDetails]); |
|
|
|
|
useSocketListener("chat/pined-message", onPinedMessage, [chatDetails]); |
|
|
|
|
useSocketListener("chat/delete-message", onDeleteChatMessage, [chatDetails]); |
|
|
|
|