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>({
32
32
const [ is_not_valid , setIsNotValid ] = useState ( false ) ;
33
33
34
34
useEffect ( ( ) => {
35
- if ( error && error . code === 'AuthorizationRequired' ) {
35
+ if (
36
+ error &&
37
+ typeof error === 'object' &&
38
+ 'code' in error &&
39
+ error . code === 'AuthorizationRequired'
40
+ ) {
36
41
setToggleModal ( true ) ;
37
42
}
38
43
} , [ error ] ) ;
Original file line number Diff line number Diff line change @@ -206,7 +206,22 @@ describe('Use WS', () => {
206
206
} ,
207
207
} ) ;
208
208
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
+ } ) ;
210
225
expect ( result . current . is_loading ) . toBeFalsy ( ) ;
211
226
} ) ;
212
227
} ) ;
Original file line number Diff line number Diff line change @@ -6,15 +6,10 @@ import {
6
6
} from '@site/src/configs/websocket/types' ;
7
7
import { useCallback , useState } from 'react' ;
8
8
9
- type TError = {
10
- code ?: string ;
11
- message ?: string ;
12
- } ;
13
-
14
9
const useSubscription = < T extends TSocketSubscribableEndpointNames > ( name : T ) => {
15
10
const [ is_loading , setIsLoading ] = useState ( false ) ;
16
11
const [ is_subscribed , setSubscribed ] = useState ( false ) ;
17
- const [ error , setError ] = useState < TError > ( ) ;
12
+ const [ error , setError ] = useState < unknown > ( ) ;
18
13
const [ data , setData ] = useState < TSocketResponseData < T > > ( ) ;
19
14
const [ full_response , setFullResponse ] = useState < TSocketResponse < T > > ( ) ;
20
15
const [ subscriber , setSubscriber ] = useState < { unsubscribe ?: VoidFunction } > ( ) ;
@@ -30,7 +25,7 @@ const useSubscription = <T extends TSocketSubscribableEndpointNames>(name: T) =>
30
25
) ;
31
26
32
27
const onError = useCallback ( ( response : TSocketResponse < T > ) => {
33
- setError ( response . error ) ;
28
+ setError ( response ) ;
34
29
setIsLoading ( false ) ;
35
30
setFullResponse ( null ) ;
36
31
} , [ ] ) ;
You can’t perform that action at this time.
0 commit comments