Skip to content
This repository was 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 all commits
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
13 changes: 12 additions & 1 deletion src/hooks/useWs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ import {
TSocketResponse,
TSocketResponseData,
} from '@site/src/configs/websocket/types';
import { getIsBrowser } from '@site/src/utils';
import { useCallback, useState } from 'react';

const useWS = <T extends TSocketEndpointNames>(name?: T) => {
const [is_loading, setIsLoading] = useState(false);
const [error, setError] = useState<unknown>();
const [data, setData] = useState<TSocketResponseData<T>>();
const [full_response, setFullResponse] = useState<TSocketResponse<T>>();
let hash;

const isBrowser = getIsBrowser();
if (isBrowser) {
hash = window.location.hash;
}

const clear = useCallback(() => {
setError(null);
Expand All @@ -24,7 +31,11 @@ const useWS = <T extends TSocketEndpointNames>(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 };
Expand Down
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