mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-19 20:29:17 +00:00
fix: websocket handlers
This commit is contained in:
@@ -28,7 +28,7 @@ import ContactsSekeleton from "../../components/ContactsSekeleton";
|
||||
import ContactModal from "../../components/ContactModal";
|
||||
import ConfirmationModal from "../../components/ConfirmationModal/";
|
||||
|
||||
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
||||
let socket;
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
mainContainer: {
|
||||
@@ -105,6 +105,7 @@ const Contacts = () => {
|
||||
}, [searchParam, page, rowsPerPage]);
|
||||
|
||||
useEffect(() => {
|
||||
socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
||||
return () => {
|
||||
socket.disconnect();
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ import Paper from "@material-ui/core/Paper";
|
||||
import SessionInfo from "../../components/SessionInfo";
|
||||
import Qrcode from "../../components/Qrcode";
|
||||
|
||||
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
||||
let socket;
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
root: {
|
||||
@@ -54,6 +54,14 @@ const WhatsAuth = () => {
|
||||
fetchSession();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
||||
|
||||
return () => {
|
||||
socket.disconnect();
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
socket.on("qrcode", data => {
|
||||
if (data.action === "update") {
|
||||
@@ -68,10 +76,6 @@ const WhatsAuth = () => {
|
||||
history.push("/chat");
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
socket.disconnect();
|
||||
};
|
||||
}, [history]);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user