Fix duplicate new-ticket notification (toast + desktop push both fired)

appendMessage() publishes ticket.created and message.created for the
same first message of a new ticket. TicketToasts and DesktopNotifications
listened to both independently, so one new customer ticket produced two
toasts/two chimes/two OS notifications. message.created now carries
ticketIsNew so both subscribers can skip it when ticket.created already
covered the same event.
This commit is contained in:
ogrechko committed 2026-08-14 05:50:29 +00:00
1 parent 87cf045715
commit b2534b7ce8
4 files changed
+16 -3

No files matched your search

+1 -1
View File
@@ -92,7 +92,7 @@ export function TicketToasts({ currentUser }: { currentUser: { id: string; role:
if (event.type === "ticket.created") {
if (!isTicketVisibleTo(event.ticket, currentUser)) return;
pushToast("Новая заявка", event.ticket.subject, `/tickets/${event.ticket.id}`);
} else if (event.type === "message.created" && event.message.authorType === "customer") {
} else if (event.type === "message.created" && event.message.authorType === "customer" && !event.ticketIsNew) {
if (!isTicketVisibleTo({ assigneeId: event.assigneeId }, currentUser)) return;
pushToast(`Сообщение от ${event.message.authorName}`, event.message.body.slice(0, 120), `/tickets/${event.ticketId}`);
}