This repository was archived by the owner on May 13, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +24
-9
lines changed
features/Apiexplorer/SubscribeRenderer Expand file tree Collapse file tree 3 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,12 @@ function SubscribeRenderer<T extends TSocketSubscribableEndpointNames>({
3232 const [ is_not_valid , setIsNotValid ] = useState ( false ) ;
3333
3434 useEffect ( ( ) => {
35- if ( error && error . code === 'AuthorizationRequired' ) {
35+ if (
36+ error &&
37+ typeof error === 'object' &&
38+ 'code' in error &&
39+ error . code === 'AuthorizationRequired'
40+ ) {
3641 setToggleModal ( true ) ;
3742 }
3843 } , [ error ] ) ;
Original file line number Diff line number Diff line change @@ -206,7 +206,22 @@ describe('Use WS', () => {
206206 } ,
207207 } ) ;
208208
209- expect ( result . current . error ) . toEqual ( { message : 'this is an error' } ) ;
209+ expect ( result . current . error ) . toEqual ( {
210+ echo_req : {
211+ base_currency : 'USD' ,
212+ exchange_rates : 1 ,
213+ req_id : 1 ,
214+ subscribe : 1 ,
215+ } ,
216+ error : {
217+ message : 'this is an error' ,
218+ } ,
219+ msg_type : 'exchange_rates' ,
220+ req_id : 1 ,
221+ subscription : {
222+ id : '2f39f7e7-d986-33f2-080a-b0ee50cfb85c' ,
223+ } ,
224+ } ) ;
210225 expect ( result . current . is_loading ) . toBeFalsy ( ) ;
211226 } ) ;
212227} ) ;
Original file line number Diff line number Diff line change @@ -6,15 +6,10 @@ import {
66} from '@site/src/configs/websocket/types' ;
77import { useCallback , useState } from 'react' ;
88
9- type TError = {
10- code ?: string ;
11- message ?: string ;
12- } ;
13-
149const useSubscription = < T extends TSocketSubscribableEndpointNames > ( name : T ) => {
1510 const [ is_loading , setIsLoading ] = useState ( false ) ;
1611 const [ is_subscribed , setSubscribed ] = useState ( false ) ;
17- const [ error , setError ] = useState < TError > ( ) ;
12+ const [ error , setError ] = useState < unknown > ( ) ;
1813 const [ data , setData ] = useState < TSocketResponseData < T > > ( ) ;
1914 const [ full_response , setFullResponse ] = useState < TSocketResponse < T > > ( ) ;
2015 const [ subscriber , setSubscriber ] = useState < { unsubscribe ?: VoidFunction } > ( ) ;
@@ -30,7 +25,7 @@ const useSubscription = <T extends TSocketSubscribableEndpointNames>(name: T) =>
3025 ) ;
3126
3227 const onError = useCallback ( ( response : TSocketResponse < T > ) => {
33- setError ( response . error ) ;
28+ setError ( response ) ;
3429 setIsLoading ( false ) ;
3530 setFullResponse ( null ) ;
3631 } , [ ] ) ;
You can’t perform that action at this time.
0 commit comments