mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 19:59:20 +00:00
code cleanup
This commit is contained in:
@@ -15,6 +15,18 @@ class Ticket extends Sequelize.Model {
|
||||
}
|
||||
);
|
||||
|
||||
this.addHook("afterFind", async result => {
|
||||
if (result.length > 0) {
|
||||
await Promise.all(
|
||||
result.map(async ticket => {
|
||||
ticket.unreadMessages = await Message.count({
|
||||
where: { ticketId: ticket.id, read: false },
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
this.addHook("afterUpdate", async ticket => {
|
||||
ticket.unreadMessages = await Message.count({
|
||||
where: { ticketId: ticket.id, read: false },
|
||||
|
||||
@@ -251,7 +251,6 @@ const TicketsList = () => {
|
||||
socket.emit("joinNotification");
|
||||
|
||||
socket.on("ticket", data => {
|
||||
console.log("data", data);
|
||||
if (data.action === "updateUnread") {
|
||||
resetUnreadMessages(data);
|
||||
}
|
||||
@@ -287,7 +286,6 @@ const TicketsList = () => {
|
||||
}, [ticketId, userId, history]);
|
||||
|
||||
const updateTickets = ({ ticket }) => {
|
||||
console.log("recebido", ticket);
|
||||
setTickets(prevState => {
|
||||
const ticketIndex = prevState.findIndex(t => t.id === ticket.id);
|
||||
|
||||
@@ -302,8 +300,6 @@ const TicketsList = () => {
|
||||
});
|
||||
};
|
||||
|
||||
console.log(tickets);
|
||||
|
||||
const deleteTicket = ({ ticketId }) => {
|
||||
setTickets(prevState => {
|
||||
const ticketIndex = prevState.findIndex(ticket => ticket.id === ticketId);
|
||||
|
||||
Reference in New Issue
Block a user