improvement: better names on wbot methods

This commit is contained in:
canove
2020-09-05 15:43:52 -03:00
parent b8ff993e6f
commit 40e2e5e8a6
8 changed files with 160 additions and 92 deletions

View File

@@ -47,6 +47,8 @@ const reducer = (state, action) => {
if (action.type === "DELETE_SESSION") {
const sessionId = action.payload;
console.log("cai aqui", sessionId);
const sessionIndex = state.findIndex(s => s.id === sessionId);
if (sessionIndex !== -1) {
state.splice(sessionIndex, 1);
@@ -123,6 +125,12 @@ const WhatsAuth = () => {
}
});
socket.on("session", data => {
if (data.action === "delete") {
dispatch({ type: "DELETE_SESSION", payload: data.sessionId });
}
});
return () => {
socket.disconnect();
};