ignore of ping in support sse
Some checks failed
Deploy / CreateImage (push) Failing after 22m19s
Deploy / DeployService (push) Failing after 21s

This commit is contained in:
Nastya 2025-03-07 00:58:13 +03:00
parent abcdbe4225
commit 2ab2bf909b
3 changed files with 11 additions and 4 deletions

@ -26,6 +26,7 @@ export interface Ticket {
title: string; title: string;
created_at: string; created_at: string;
updated_at: string; updated_at: string;
system?: boolean;
rate: number; rate: number;
} }

@ -33,10 +33,15 @@ export default function Support() {
onFetchStateChange: setTicketsFetchState, onFetchStateChange: setTicketsFetchState,
}); });
useSSESubscription<Ticket>({ useSSESubscription<Ticket | [{event: "ping"}]>({
enabled: Boolean(token), enabled: Boolean(token),
url: process.env.REACT_APP_DOMAIN + `/heruvym/v1.0.0/subscribe?Authorization=${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: () => { onDisconnect: () => {
clearMessageState(); clearMessageState();
clearTickets(); clearTickets();

@ -22,12 +22,13 @@ export default function TicketItem({ ticket, setActiveUserId }: Props) {
const navigate = useNavigate(); const navigate = useNavigate();
const ticketId = useParams().ticketId; 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 isSelected = ticket.id === ticketId;
const unreadSx = { const unreadSx = {
border: "1px solid", border: "1px solid",
borderColor: theme.palette.golden.main, borderColor: ticket.system ? "red" : theme.palette.golden.main,
backgroundColor: theme.palette.goldenMedium.main, backgroundColor: theme.palette.goldenMedium.main,
}; };