From 9bcfe0173e74892bd42c64cac9f3488bc83860da Mon Sep 17 00:00:00 2001 From: Jahongir Yusupov <91022355+jahongiry@users.noreply.github.com> Date: Sun, 18 Feb 2024 15:47:24 +0500 Subject: [PATCH] Add Last test --- src/App.js | 4 ++-- src/pages/chat/Chat.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/App.js b/src/App.js index 1c74677..805876a 100644 --- a/src/App.js +++ b/src/App.js @@ -29,14 +29,14 @@ import UcOffer from './pages/offer/UcOffer'; function App() { const dispatch = useDispatch(); const { pathname } = useLocation(); - const token = useSelector((state) => state.auth.token); + const token = localStorage.getItem('token'); useEffect(() => { const storedToken = localStorage.getItem('token'); if (storedToken) { dispatch(checkLogIn()); } - }, [dispatch]); + }, [dispatch, token]); useEffect(() => { window.scrollTo(0, 0); diff --git a/src/pages/chat/Chat.js b/src/pages/chat/Chat.js index 415262e..fe30b73 100644 --- a/src/pages/chat/Chat.js +++ b/src/pages/chat/Chat.js @@ -22,8 +22,9 @@ const Chat = () => { useEffect(() => { if (token) { const newSocket = io('https://cyberswap.uz', { + path: '/api/socket.io', query: { token: encodeURIComponent(token) }, - transports: ['websocket'], // use WebSocket first, fallback to polling if necessary + transports: ['websocket'], }); setSocket(newSocket);