code cleanup

This commit is contained in:
canove
2020-09-06 12:13:26 -03:00
parent b0f28c16ad
commit 72c7c83110
2 changed files with 4 additions and 8 deletions

View File

@@ -86,10 +86,8 @@ module.exports = {
return null; return null;
}, },
getWbot: sessionId => { getWbot: whatsappId => {
console.log(sessionId); const sessionIndex = sessions.findIndex(s => s.id === whatsappId);
console.log(sessions.map(session => session.id));
const sessionIndex = sessions.findIndex(s => s.id === sessionId);
if (sessionIndex === -1) { if (sessionIndex === -1) {
throw new Error("This Wbot session is not initialized"); throw new Error("This Wbot session is not initialized");
@@ -97,9 +95,9 @@ module.exports = {
return sessions[sessionIndex]; return sessions[sessionIndex];
}, },
removeWbot: sessionId => { removeWbot: whatsappId => {
try { try {
const sessionIndex = sessions.findIndex(s => s.id === sessionId); const sessionIndex = sessions.findIndex(s => s.id === whatsappId);
if (sessionIndex !== -1) { if (sessionIndex !== -1) {
sessions[sessionIndex].destroy(); sessions[sessionIndex].destroy();
sessions.splice(sessionIndex, 1); sessions.splice(sessionIndex, 1);

View File

@@ -28,7 +28,6 @@ const QrcodeModal = ({ open, onClose, whatsAppId }) => {
useEffect(() => { useEffect(() => {
if (!whatsAppId) return; if (!whatsAppId) return;
const socket = openSocket(process.env.REACT_APP_BACKEND_URL); const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
console.log("connectiing");
socket.on("whatsappSession", data => { socket.on("whatsappSession", data => {
if (data.action === "update" && data.session.id === whatsAppId) { if (data.action === "update" && data.session.id === whatsAppId) {
@@ -42,7 +41,6 @@ const QrcodeModal = ({ open, onClose, whatsAppId }) => {
return () => { return () => {
socket.disconnect(); socket.disconnect();
console.log("disconnectiing");
}; };
}, [whatsAppId, onClose]); }, [whatsAppId, onClose]);