diff --git a/src/App.tsx b/src/App.tsx index fe4f490..b57a9c5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -31,6 +31,7 @@ const App: React.FC = () => { }); const [spinning, setSpinning] = useState(false); const [isState, setIsState] = useState(true); + const [isSignalr, setIsSignalr] = useState(true); useEffect(() => { let userInfo = JSON.parse(storage.getItem('user') as string) let loginInfo = JSON.parse(storage.getItem('login') as string) @@ -44,27 +45,7 @@ const App: React.FC = () => { storage.setItem('user', JSON.stringify(res.data)) toSrc('/home') await startSignalr() - onOtherSignalr(async (item: any) => { - switch (item.key) { - case 'Invitation': - window.electron.joinNotification({ - body: item.roomName, - name: item.InviterName, - }) - joinMeetingModalRef.current.changeModal(item) - break; - case 'ForceLogout': - if (item.msg) { - message.error(item.msg) - } - await leaveChannel(true) - toSrc('/login') - break; - } - }) - onReconnected(async () => { - storage.setItem('reconnect', true) - }) + onEventSignalr() } else { toSrc('/login') } @@ -172,6 +153,7 @@ const App: React.FC = () => { } }) } + onEventSignalr() storage.setItem('stateInfo', JSON.stringify(state)) }, [state]) const handleResize = (): void => { @@ -188,6 +170,32 @@ const App: React.FC = () => { } }; + const onEventSignalr = (): void => { + if (isSignalr) { + setIsSignalr(false) + onOtherSignalr(async (item: any) => { + switch (item.key) { + case 'Invitation': + window.electron.joinNotification({ + body: item.roomName, + name: item.InviterName, + }) + joinMeetingModalRef.current.changeModal(item) + break; + case 'ForceLogout': + if (item.msg) { + message.error(item.msg) + } + await leaveChannel(true) + toSrc('/login') + break; + } + }) + onReconnected(async () => { + storage.setItem('reconnect', true) + }) + } + } const toSrc = (path: string): void => { switch (path) { case '/login':