From b5cf760b42934290cdda9ca78308747db22c44f4 Mon Sep 17 00:00:00 2001 From: Robson Tenorio Henriques Date: Tue, 29 Oct 2024 07:53:01 -0300 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=A3o=20de=20warnings=20nos=20tick?= =?UTF-8?q?ets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/TicketListItem/index.js | 17 +++++++++++++---- frontend/src/components/TicketsList/index.js | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/TicketListItem/index.js b/frontend/src/components/TicketListItem/index.js index b90122ad..7324e6f4 100644 --- a/frontend/src/components/TicketListItem/index.js +++ b/frontend/src/components/TicketListItem/index.js @@ -205,20 +205,29 @@ const TicketListItem = ({ ticket, userId, filteredTags }) => { const [uName, setUserName] = useState(null); useEffect(() => { + isMounted.current = true; + const delayDebounceFn = setTimeout(() => { const fetchTicket = async () => { + if (!isMounted.current) return; + try { const { data } = await api.get("/tickets/" + ticket.id); - setTag(data?.contact?.tags); + if (isMounted.current) { + setTag(data?.contact?.tags); + } } catch (err) { + if (isMounted.current) { + toastError(err); + } } }; fetchTicket(); }, 500); + return () => { - if (delayDebounceFn !== null) { - clearTimeout(delayDebounceFn); - } + clearTimeout(delayDebounceFn); + isMounted.current = false; }; }, [ticket.id, user, history]); diff --git a/frontend/src/components/TicketsList/index.js b/frontend/src/components/TicketsList/index.js index d3b78f15..6ca9bd3d 100644 --- a/frontend/src/components/TicketsList/index.js +++ b/frontend/src/components/TicketsList/index.js @@ -297,6 +297,9 @@ const TicketsList = (props) => { }); return () => { + socket.off("ticket"); + socket.off("appMessage"); + socket.off("contact"); socket.disconnect(); }; }, [status, showAll, user, selectedQueueIds]);