feat: remoteTickesControll listeners

websocket
adriano 2024-05-23 17:39:42 -03:00
parent 435a577bed
commit 83d197f240
2 changed files with 10 additions and 7 deletions

View File

@ -154,12 +154,14 @@ const TicketListItem = ({ ticket, remoteTicketsControll, settings }) => {
useEffect(() => {
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
socket.on('remoteTickesControll', (data) => {
const onRemoteTickesControllTicketListItem = (data) => {
console.log('REMOTE TICKETS CONTROLL UPDATE2: ', data.tickets)
if (data.action === 'update') {
setRemoteTicketsControll(data.tickets)
}
})
}
socket.on('remoteTickesControll', onRemoteTickesControllTicketListItem)
const onSettingsTicketListItem = (data) => {
if (data.action === 'update') {
@ -175,7 +177,7 @@ const TicketListItem = ({ ticket, remoteTicketsControll, settings }) => {
socket.on('settings', onSettingsTicketListItem)
return () => {
socket.removeAllListeners('remoteTickesControll');
socket.off('remoteTickesControll', onRemoteTickesControllTicketListItem);
socket.off('settings', onSettingsTicketListItem);
}
}, [])

View File

@ -323,13 +323,14 @@ const TicketsList = (props) => {
}
})
socket.on('remoteTickesControll', (data) => {
const onRemoteTickesControllTicketList = (data) => {
console.log('REMOTE TICKETS CONTROLL UPDATE 1: ', data.tickets)
if (data.action === 'update') {
setRemoteTicketsControll(data.tickets)
}
})
}
socket.on('remoteTickesControll', onRemoteTickesControllTicketList)
const onSettingsTicketList = (data) => {
if (data.action === 'update') {
@ -350,7 +351,7 @@ const TicketsList = (props) => {
socket.removeAllListeners("contact")
socket.off('connect', onConnectTicketList);
socket.off('settings', onSettingsTicketList);
socket.removeAllListeners('remoteTickesControll');
socket.off('remoteTickesControll', onRemoteTickesControllTicketList);
}
}, [status, showAll, user, selectedQueueIds, tab])