From 2ab2bf909b77dbaeb2b3cf883c6da28777bf4210 Mon Sep 17 00:00:00 2001 From: Nastya Date: Fri, 7 Mar 2025 00:58:13 +0300 Subject: [PATCH] ignore of ping in support sse --- src/model/ticket.ts | 1 + src/pages/dashboard/Content/Support/Support.tsx | 9 +++++++-- .../dashboard/Content/Support/TicketList/TicketItem.tsx | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/model/ticket.ts b/src/model/ticket.ts index 4be39e3..ed22f6e 100644 --- a/src/model/ticket.ts +++ b/src/model/ticket.ts @@ -26,6 +26,7 @@ export interface Ticket { title: string; created_at: string; updated_at: string; + system?: boolean; rate: number; } diff --git a/src/pages/dashboard/Content/Support/Support.tsx b/src/pages/dashboard/Content/Support/Support.tsx index 47c968b..488079d 100644 --- a/src/pages/dashboard/Content/Support/Support.tsx +++ b/src/pages/dashboard/Content/Support/Support.tsx @@ -33,10 +33,15 @@ export default function Support() { onFetchStateChange: setTicketsFetchState, }); - useSSESubscription({ + useSSESubscription({ enabled: Boolean(token), url: process.env.REACT_APP_DOMAIN + `/heruvym/v1.0.0/subscribe?Authorization=${token}`, - onNewData: updateTickets, + onNewData: (e) => { + + if ("event" in e[0] && e[0].event === "ping") return + + updateTickets(e as Ticket[]) + }, onDisconnect: () => { clearMessageState(); clearTickets(); diff --git a/src/pages/dashboard/Content/Support/TicketList/TicketItem.tsx b/src/pages/dashboard/Content/Support/TicketList/TicketItem.tsx index 03deacd..ee26d6a 100644 --- a/src/pages/dashboard/Content/Support/TicketList/TicketItem.tsx +++ b/src/pages/dashboard/Content/Support/TicketList/TicketItem.tsx @@ -22,12 +22,13 @@ export default function TicketItem({ ticket, setActiveUserId }: Props) { const navigate = useNavigate(); const ticketId = useParams().ticketId; - const isUnread = ticket.user === ticket.top_message.user_id; + console.log(ticket) + const isUnread = ticket.user === ticket?.top_message?.user_id; const isSelected = ticket.id === ticketId; const unreadSx = { border: "1px solid", - borderColor: theme.palette.golden.main, + borderColor: ticket.system ? "red" : theme.palette.golden.main, backgroundColor: theme.palette.goldenMedium.main, };