mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-21 05:09:18 +00:00
code cleanup
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
@@ -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]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user