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

View File

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