Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

fix: playground fix for api token call #274

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/hooks/useWs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useHistory, useLocation } from '@docusaurus/router';
import apiManager from '@site/src/configs/websocket';
import {
TSocketEndpointNames,
Expand All @@ -11,6 +12,8 @@ const useWS = <T extends TSocketEndpointNames>(name?: T) => {
const [error, setError] = useState<unknown>();
const [data, setData] = useState<TSocketResponseData<T>>();
const [full_response, setFullResponse] = useState<TSocketResponse<T>>();
const history = useHistory();
const { hash, pathname } = useLocation();

const clear = useCallback(() => {
setError(null);
Expand All @@ -21,10 +24,15 @@ const useWS = <T extends TSocketEndpointNames>(name?: T) => {
const send = useCallback(
async (data?: Parameters<typeof apiManager.augmentedSend<T>>[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 };
Expand Down
Loading