fix: bugs de atualizacao dos tickets tempo real

websocket
adriano 2024-05-20 17:24:06 -03:00
parent 62f137d884
commit 7bb73cfa19
4 changed files with 6 additions and 4 deletions

View File

@ -452,14 +452,14 @@ const MessagesList = ({ ticketId, isGroup }) => {
const onAppMessageMessagesList = (data) => { const onAppMessageMessagesList = (data) => {
if (data.action === "create") { if (data.action === "create" && data.ticket.id == ticketId) {
dispatch({ type: "ADD_MESSAGE", payload: data.message }) dispatch({ type: "ADD_MESSAGE", payload: data.message })
scrollToBottom() scrollToBottom()
} }
if (data.action === "update") { if (data.action === "update" && data.ticket.id == ticketId) {
dispatch({ type: "UPDATE_MESSAGE", payload: data.message }) dispatch({ type: "UPDATE_MESSAGE", payload: data.message })
} }
} }
@ -467,6 +467,7 @@ const MessagesList = ({ ticketId, isGroup }) => {
socket.on("appMessage", onAppMessageMessagesList) socket.on("appMessage", onAppMessageMessagesList)
return () => { return () => {
socket.emit("leaveChatBox", ticketId)
socket.off("connect", onConnectMessagesList) socket.off("connect", onConnectMessagesList)
socket.off("appMessage", onAppMessageMessagesList) socket.off("appMessage", onAppMessageMessagesList)
} }

View File

@ -143,7 +143,7 @@ const Ticket = () => {
socket.on("connect", onConnectTicket) socket.on("connect", onConnectTicket)
const onTicketTicket = (data) => { const onTicketTicket = (data) => {
if (data.action === "update") { if (data.action === "update" && data.ticket.id == ticketId) {
setTicket(data.ticket) setTicket(data.ticket)
} }

View File

@ -246,6 +246,7 @@ const TicketsList = (props) => {
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL) //const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
const shouldUpdateTicket = ticket => const shouldUpdateTicket = ticket =>
(status === ticket.status) &&
(!ticket.userId || ticket.userId === user?.id || showAll) && (!ticket.userId || ticket.userId === user?.id || showAll) &&
(!ticket.queueId || selectedQueueIds.indexOf(ticket.queueId) > -1) (!ticket.queueId || selectedQueueIds.indexOf(ticket.queueId) > -1)

View File

@ -262,7 +262,7 @@ const TransferTicketModal = ({ modalOpen, onClose, ticketid }) => {
required required
> >
<MenuItem style={{ background: "white", }} value={''}>&nbsp;</MenuItem> <MenuItem style={{ background: "white", }} value={''}>&nbsp;</MenuItem>
{queues.map((queue) => ( {queues?.map((queue) => (
<MenuItem <MenuItem
key={queue.id} key={queue.id}
value={queue.id} value={queue.id}