diff --git a/src/hooks/useWs/index.tsx b/src/hooks/useWs/index.tsx index 4a2c96c5..afc24fd0 100644 --- a/src/hooks/useWs/index.tsx +++ b/src/hooks/useWs/index.tsx @@ -4,6 +4,7 @@ import { TSocketResponse, TSocketResponseData, } from '@site/src/configs/websocket/types'; +import { getIsBrowser } from '@site/src/utils'; import { useCallback, useState } from 'react'; const useWS = (name?: T) => { @@ -11,6 +12,12 @@ const useWS = (name?: T) => { const [error, setError] = useState(); const [data, setData] = useState>(); const [full_response, setFullResponse] = useState>(); + let hash; + + const isBrowser = getIsBrowser(); + if (isBrowser) { + hash = window.location.hash; + } const clear = useCallback(() => { setError(null); @@ -24,7 +31,11 @@ const useWS = (name?: T) => { if (name) { if (payload === undefined || name == 'api_token' || name == 'app_register') { - payload = { [name]: 1, ...payload }; + if (hash === '#api_token' || hash === '#app_register') { + payload = { ...payload }; + } else { + payload = { [name]: 1, ...payload }; + } } } else { payload = { ...payload };