From d041403f115bcdc712d599cbbd716847098e0359 Mon Sep 17 00:00:00 2001 From: sanjam chhatwal Date: Mon, 18 Dec 2023 12:01:50 +0400 Subject: [PATCH 1/5] fix: playground fix for api token call --- src/hooks/useWs/index.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/hooks/useWs/index.tsx b/src/hooks/useWs/index.tsx index 4a2c96c54..d4318958f 100644 --- a/src/hooks/useWs/index.tsx +++ b/src/hooks/useWs/index.tsx @@ -1,3 +1,4 @@ +import { useHistory, useLocation } from '@docusaurus/router'; import apiManager from '@site/src/configs/websocket'; import { TSocketEndpointNames, @@ -11,6 +12,8 @@ const useWS = (name?: T) => { const [error, setError] = useState(); const [data, setData] = useState>(); const [full_response, setFullResponse] = useState>(); + const history = useHistory(); + const { hash, pathname } = useLocation(); const clear = useCallback(() => { setError(null); @@ -21,10 +24,15 @@ const useWS = (name?: T) => { const send = useCallback( async (data?: Parameters>[0]) => { let payload = data; + console.log(hash); if (name) { if (payload === undefined || name == 'api_token' || name == 'app_register') { - payload = { [name]: 1, ...payload }; + if (hash === '#api_token') { + payload = { ...payload }; + } else { + payload = { [name]: 1, ...payload }; + } } } else { payload = { ...payload }; From 742dd486f5519d4e6fa7b4fb6e72f5f0be9c7287 Mon Sep 17 00:00:00 2001 From: sanjam chhatwal Date: Mon, 18 Dec 2023 15:26:20 +0400 Subject: [PATCH 2/5] fix: playground fix for api token call --- src/hooks/useWs/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/hooks/useWs/index.tsx b/src/hooks/useWs/index.tsx index d4318958f..5373a8e72 100644 --- a/src/hooks/useWs/index.tsx +++ b/src/hooks/useWs/index.tsx @@ -1,4 +1,3 @@ -import { useHistory, useLocation } from '@docusaurus/router'; import apiManager from '@site/src/configs/websocket'; import { TSocketEndpointNames, @@ -12,8 +11,7 @@ const useWS = (name?: T) => { const [error, setError] = useState(); const [data, setData] = useState>(); const [full_response, setFullResponse] = useState>(); - const history = useHistory(); - const { hash, pathname } = useLocation(); + const hash = window.location.hash; const clear = useCallback(() => { setError(null); From ec6c5b7a5a63a4d6e17eb23f0de06adaf1974adc Mon Sep 17 00:00:00 2001 From: sanjam chhatwal Date: Mon, 18 Dec 2023 15:26:53 +0400 Subject: [PATCH 3/5] fix: playground fix for api token call --- src/hooks/useWs/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hooks/useWs/index.tsx b/src/hooks/useWs/index.tsx index 5373a8e72..541a485e4 100644 --- a/src/hooks/useWs/index.tsx +++ b/src/hooks/useWs/index.tsx @@ -22,11 +22,10 @@ const useWS = (name?: T) => { const send = useCallback( async (data?: Parameters>[0]) => { let payload = data; - console.log(hash); if (name) { if (payload === undefined || name == 'api_token' || name == 'app_register') { - if (hash === '#api_token') { + if (hash === '#api_token' || hash === '#app_register') { payload = { ...payload }; } else { payload = { [name]: 1, ...payload }; From e190850e6c411899a79c09a708257bd4c3e6da97 Mon Sep 17 00:00:00 2001 From: sanjam chhatwal Date: Mon, 18 Dec 2023 15:40:22 +0400 Subject: [PATCH 4/5] fix: test fix --- src/hooks/useWs/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useWs/index.tsx b/src/hooks/useWs/index.tsx index 541a485e4..048c54d10 100644 --- a/src/hooks/useWs/index.tsx +++ b/src/hooks/useWs/index.tsx @@ -11,7 +11,7 @@ const useWS = (name?: T) => { const [error, setError] = useState(); const [data, setData] = useState>(); const [full_response, setFullResponse] = useState>(); - const hash = window.location.hash; + const hash = location.hash; const clear = useCallback(() => { setError(null); From 4b6277c7a6927e848cf994023bbf38465c11e840 Mon Sep 17 00:00:00 2001 From: sanjam chhatwal Date: Mon, 18 Dec 2023 16:28:44 +0400 Subject: [PATCH 5/5] fix: test fix --- src/hooks/useWs/index.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hooks/useWs/index.tsx b/src/hooks/useWs/index.tsx index 048c54d10..afc24fd0b 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,7 +12,12 @@ const useWS = (name?: T) => { const [error, setError] = useState(); const [data, setData] = useState>(); const [full_response, setFullResponse] = useState>(); - const hash = location.hash; + let hash; + + const isBrowser = getIsBrowser(); + if (isBrowser) { + hash = window.location.hash; + } const clear = useCallback(() => { setError(null); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy