|
|
@@ -8,24 +8,23 @@ const Book = () => {
|
|
|
const [onlineList, setOnlineList] = useState([])
|
|
|
const { initialState } = useModel('@@initialState')
|
|
|
|
|
|
- const { username, staffId: id, wsToken: token } = initialState?.currentUser
|
|
|
- // if (!currentUser) return null
|
|
|
- // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
|
useEffect(() => {
|
|
|
- id &&
|
|
|
- ws.init(`ws://cld2qa.com/summon/v1/chat/link?username=${username}&id=${id}&token=${token}`, {
|
|
|
- onMessage: msg => {
|
|
|
- onMessage(msg)
|
|
|
- if (msg?.cmd === CmdType.OnlineBook) {
|
|
|
- setOnlineList(msg.onlineStaff)
|
|
|
+ if (initialState?.currentUser) {
|
|
|
+ const { username, staffId: id, wsToken: token } = initialState?.currentUser
|
|
|
+ id &&
|
|
|
+ ws.init(
|
|
|
+ `ws://cld2qa.com/summon/v1/chat/link?username=${username}&id=${id}&token=${token}`,
|
|
|
+ {
|
|
|
+ onMessage: msg => {
|
|
|
+ onMessage(msg)
|
|
|
+ if (msg?.cmd === CmdType.OnlineBook) {
|
|
|
+ setOnlineList(msg.onlineStaff)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- return () => {
|
|
|
- ws.disconnect()
|
|
|
+ )
|
|
|
}
|
|
|
- }, [])
|
|
|
+ }, [initialState?.currentUser])
|
|
|
return (
|
|
|
<div className="fixed top-12 right-0">
|
|
|
<div className="relative flex flex-row items-center">
|