Skip to content

Commit

Permalink
Correção de warnings nos tickets
Browse files Browse the repository at this point in the history
  • Loading branch information
rtenorioh committed Oct 29, 2024
1 parent 68d8e82 commit b5cf760
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 13 additions & 4 deletions frontend/src/components/TicketListItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/TicketsList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ const TicketsList = (props) => {
});

return () => {
socket.off("ticket");
socket.off("appMessage");
socket.off("contact");
socket.disconnect();
};
}, [status, showAll, user, selectedQueueIds]);
Expand Down

0 comments on commit b5cf760

Please sign in to comment.