fix: updating contact does not contact data in ticket list

This commit is contained in:
canove
2020-09-26 13:01:38 -03:00
parent abe0b84b83
commit 03dcfdcbcd

View File

@@ -125,6 +125,15 @@ const reducer = (state, action) => {
return [...state];
}
if (action.type === "UPDATE_TICKET_CONTACT") {
const contact = action.payload;
const ticketIndex = state.findIndex(t => t.contactId === contact.id);
if (ticketIndex !== -1) {
state[ticketIndex].contact = contact;
}
return [...state];
}
if (action.type === "DELETE_TICKET") {
const ticketId = action.payload;
const ticketIndex = state.findIndex(t => t.id === ticketId);
@@ -201,6 +210,15 @@ const TicketsList = ({ status, searchParam, showAll }) => {
}
});
socket.on("contact", data => {
if (data.action === "update") {
dispatch({
type: "UPDATE_TICKET_CONTACT",
payload: data.contact,
});
}
});
return () => {
socket.disconnect();
};