This repository was archived by the owner on May 13, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 66} from '@site/src/configs/websocket/types' ;
77import { useCallback , useState } from 'react' ;
88
9- const useWS = < T extends TSocketEndpointNames > ( name : T ) => {
9+ const useWS = < T extends TSocketEndpointNames > ( name ? : T ) => {
1010 const [ is_loading , setIsLoading ] = useState ( false ) ;
1111 const [ error , setError ] = useState < unknown > ( ) ;
1212 const [ data , setData ] = useState < TSocketResponseData < T > > ( ) ;
@@ -19,10 +19,20 @@ const useWS = <T extends TSocketEndpointNames>(name: T) => {
1919 } , [ ] ) ;
2020
2121 const send = useCallback (
22- async ( data ?: Parameters < typeof apiManager . augmentedSend < T > > [ 1 ] ) => {
22+ async ( data ?: Parameters < typeof apiManager . augmentedSend < T > > [ ] ) => {
23+ let payload : any = data ;
24+ console . log ( ) ;
25+
26+ if ( name ) {
27+ payload = { ...payload , name : { [ name ] : 1 } } ;
28+ } else {
29+ payload = { ...payload } ;
30+ }
31+
2332 setIsLoading ( true ) ;
33+
2434 try {
25- const response = await apiManager . augmentedSend ( name , data ) ;
35+ const response = await apiManager . augmentedSend ( payload ) ;
2636 const key = response [ 'msg_type' ] ?? name ;
2737 setData ( response [ key ] as TSocketResponseData < T > ) ;
2838 setFullResponse ( response ) ;
You can’t perform that action at this time.
0 commit comments