From d39c0eb21303221c22be5cdd4fd3703af457fe66 Mon Sep 17 00:00:00 2001 From: Horgun Date: Mon, 19 Sep 2022 15:00:06 -0400 Subject: [PATCH 1/2] Corrige a busca no whaticket Estavam aparecendo mensagens novas na busca e a busca estava trazendo resultados da busca anterior --- frontend/src/components/TicketsList/index.js | 6 +++--- frontend/src/components/TicketsManager/index.js | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/TicketsList/index.js b/frontend/src/components/TicketsList/index.js index d10b3e9..abd1b28 100644 --- a/frontend/src/components/TicketsList/index.js +++ b/frontend/src/components/TicketsList/index.js @@ -179,12 +179,12 @@ const reducer = (state, action) => { type: "LOAD_TICKETS", payload: tickets, }); - }, [tickets, status, searchParam]); + }, [tickets]); useEffect(() => { const socket = openSocket(); - const shouldUpdateTicket = ticket => + const shouldUpdateTicket = ticket => !searchParam && (!ticket.userId || ticket.userId === user?.id || showAll) && (!ticket.queueId || selectedQueueIds.indexOf(ticket.queueId) > -1); @@ -244,7 +244,7 @@ const reducer = (state, action) => { return () => { socket.disconnect(); }; - }, [status, showAll, user, selectedQueueIds]); + }, [status, searchParam, showAll, user, selectedQueueIds]); useEffect(() => { if (typeof updateCount === "function") { diff --git a/frontend/src/components/TicketsManager/index.js b/frontend/src/components/TicketsManager/index.js index 88e6ea0..6888322 100644 --- a/frontend/src/components/TicketsManager/index.js +++ b/frontend/src/components/TicketsManager/index.js @@ -118,6 +118,7 @@ const TicketsManager = () => { useEffect(() => { if (tab === "search") { searchInputRef.current.focus(); + setSearchParam(""); } }, [tab]); From d2331be3ccd06ef8f43ad5179df00b128b364ceb Mon Sep 17 00:00:00 2001 From: Horgun Date: Mon, 19 Sep 2022 15:03:41 -0400 Subject: [PATCH 2/2] Bug no scroll Ao rolar a fila de tickets estava pulando uma pagina na chamada ao backend (que eu testei estava pulando da pagina 1 direto pra 3), isso eu testei na parte da busca tb. --- frontend/src/components/TicketsList/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/components/TicketsList/index.js b/frontend/src/components/TicketsList/index.js index abd1b28..37e5de5 100644 --- a/frontend/src/components/TicketsList/index.js +++ b/frontend/src/components/TicketsList/index.js @@ -263,6 +263,7 @@ const reducer = (state, action) => { const { scrollTop, scrollHeight, clientHeight } = e.currentTarget; if (scrollHeight - (scrollTop + 100) < clientHeight) { + e.currentTarget.scrollTop = scrollTop - 100; loadMore(); } };