Compare commits
2 Commits
3ced558b18
...
435a577bed
Author | SHA1 | Date |
---|---|---|
adriano | 435a577bed | |
adriano | fce5554681 |
|
@ -451,15 +451,16 @@ const MessagesList = ({ ticketId, isGroup }) => {
|
||||||
socket.on("connect", onConnectMessagesList)
|
socket.on("connect", onConnectMessagesList)
|
||||||
|
|
||||||
const onAppMessageMessagesList = (data) => {
|
const onAppMessageMessagesList = (data) => {
|
||||||
|
if (+data.message.ticketId !== +ticketId) return
|
||||||
|
|
||||||
if (data.action === "create" && data.ticket.id == ticketId) {
|
if (data.action === "create") {
|
||||||
|
|
||||||
dispatch({ type: "ADD_MESSAGE", payload: data.message })
|
dispatch({ type: "ADD_MESSAGE", payload: data.message })
|
||||||
|
|
||||||
scrollToBottom()
|
scrollToBottom()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.action === "update" && data.ticket.id == ticketId) {
|
if (data.action === "update") {
|
||||||
dispatch({ type: "UPDATE_MESSAGE", payload: data.message })
|
dispatch({ type: "UPDATE_MESSAGE", payload: data.message })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,11 +143,15 @@ const Ticket = () => {
|
||||||
socket.on("connect", onConnectTicket)
|
socket.on("connect", onConnectTicket)
|
||||||
|
|
||||||
const onTicketTicket = (data) => {
|
const onTicketTicket = (data) => {
|
||||||
if (data.action === "update" && data.ticket.id == ticketId) {
|
const isSameTicket = +data?.ticket?.id === +ticketId || +data.ticketId === +ticketId
|
||||||
|
if (!isSameTicket) return
|
||||||
|
|
||||||
|
if (data.action === "update") {
|
||||||
setTicket(data.ticket)
|
setTicket(data.ticket)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.action === "delete") {
|
if (data.action === "deleteForever") {
|
||||||
|
console.log('delete forever')
|
||||||
toast.success("Ticket deleted sucessfully.")
|
toast.success("Ticket deleted sucessfully.")
|
||||||
history.push("/tickets")
|
history.push("/tickets")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue