fix: deleting a ticket with unreadMessages keeps ticket in notifications

This commit is contained in:
canove
2020-09-29 06:20:16 -03:00
parent c36096c4b9
commit d78df2bf2e
2 changed files with 3 additions and 2 deletions

View File

@@ -101,6 +101,7 @@ export const remove = async (
const io = getIO();
io.to(ticket.status)
.to(ticketId)
.to("notification")
.emit("ticket", {
action: "delete",
ticketId: +ticketId

View File

@@ -73,7 +73,7 @@ const NotificationsPopOver = () => {
socket.emit("joinNotification");
socket.on("ticket", data => {
if (data.action === "updateUnread") {
if (data.action === "updateUnread" || data.action === "delete") {
setNotifications(prevState => {
const ticketIndex = prevState.findIndex(t => t.id === data.ticketId);
if (ticketIndex !== -1) {
@@ -103,7 +103,7 @@ const NotificationsPopOver = () => {
(ticketIdRef.current &&
data.message.ticketId === ticketIdRef.current &&
document.visibilityState === "visible") ||
(data.ticket.userId !== userId && data.ticket.userId)
(data.ticket.userId && data.ticket.userId !== userId)
)
return;
else {