CFE-11 change transport protocol socket and fixed bug toast container connection
This commit is contained in:
@@ -11,6 +11,7 @@ const NetworkComponent = () => {
|
||||
const t = useTranslations()
|
||||
|
||||
useEffect(() => {
|
||||
console.log(network.online)
|
||||
if (network.online) {
|
||||
toast.update(networkToastId.current, {
|
||||
type: toast.TYPE.SUCCESS,
|
||||
@@ -23,6 +24,8 @@ const NetworkComponent = () => {
|
||||
return
|
||||
}
|
||||
networkToastId.current = toast.warn(t('offline_message'), {
|
||||
containerId: 'connection',
|
||||
draggable: false,
|
||||
autoClose: false, closeButton: false, closeOnClick: false, icon: <WifiOffIcon/>
|
||||
})
|
||||
}, [network.online]);
|
||||
|
||||
@@ -53,6 +53,11 @@ function AppLayout({children, isBot}) {
|
||||
containerId="validation"
|
||||
position={directionApp === "ltr" ? "top-left" : "top-right"}
|
||||
rtl={directionApp === 'rtl'}/>
|
||||
<ToastContainer
|
||||
enableMultiContainer
|
||||
containerId={'connection'}
|
||||
position={directionApp === "ltr" ? "top-right" : "top-left"}
|
||||
rtl={directionApp === 'rtl'}/>
|
||||
<NetworkComponent/>
|
||||
{children}
|
||||
</>
|
||||
|
||||
@@ -2,7 +2,7 @@ import {createContext, useEffect, useMemo, useRef, useState} from "react";
|
||||
import {io} from "socket.io-client";
|
||||
import useUser from "@/lib/app/hooks/useUser";
|
||||
import {useTranslations} from "next-intl";
|
||||
import {toast, ToastContainer} from "react-toastify";
|
||||
import {toast} from "react-toastify";
|
||||
import PowerIcon from "@mui/icons-material/Power";
|
||||
import PowerOffIcon from "@mui/icons-material/PowerOff";
|
||||
import useDirection from "@/lib/app/hooks/useDirection";
|
||||
@@ -17,7 +17,7 @@ export const SocketProvider = ({children}) => {
|
||||
const {directionApp} = useDirection();
|
||||
const socket = useMemo(() => io(process.env.NEXT_PUBLIC_SERVER_SOCKET_URL, {
|
||||
autoConnect: false,
|
||||
transports: ['websocket'],
|
||||
// transports: ['websocket'],
|
||||
auth: {
|
||||
token: ""
|
||||
}
|
||||
@@ -60,7 +60,7 @@ export const SocketProvider = ({children}) => {
|
||||
return
|
||||
}
|
||||
socketToastId.current = toast.warn(t('socket_is_not_connect_message'), {
|
||||
containerId: 'socket',
|
||||
containerId: 'connection',
|
||||
draggable: false,
|
||||
autoClose: false, closeButton: false, closeOnClick: false, icon: <PowerOffIcon/>
|
||||
})
|
||||
@@ -69,10 +69,6 @@ export const SocketProvider = ({children}) => {
|
||||
|
||||
return (
|
||||
<SocketContext.Provider value={{socket}}>
|
||||
<ToastContainer
|
||||
enableMultiContainer containerId={'socket'}
|
||||
position={directionApp === "ltr" ? "top-right" : "top-left"}
|
||||
rtl={directionApp === 'rtl'}/>
|
||||
{children}
|
||||
</SocketContext.Provider>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user