@@ -19,7 +19,7 @@ function getSocketFromManager(nameSpace: string) {
19
19
return socketIOManager . socket ( nameSpace ) ;
20
20
}
21
21
22
- const sendToastForError = debounce (
22
+ const sendErrorToastDebounced = debounce (
23
23
( error ) => {
24
24
toast . error ( String ( error ) ) ;
25
25
} ,
@@ -39,28 +39,28 @@ export default {
39
39
// wait for connection
40
40
await new Promise < void > ( ( resolve ) => {
41
41
socket . on ( 'connect' , ( ) => {
42
- sendToastForError . cancel ( ) ;
42
+ sendErrorToastDebounced . cancel ( ) ;
43
43
if ( onConnection ) {
44
44
onConnection ( socket ) ;
45
45
}
46
46
resolve ( ) ;
47
47
} ) ;
48
48
49
49
socket . on ( 'connect_error' , ( error : Error ) => {
50
- sendToastForError ( error . toString ( ) ) ;
50
+ sendErrorToastDebounced ( error . toString ( ) ) ;
51
51
} ) ;
52
52
53
53
socket . on ( 'connect_timeout' , ( timeout ) => {
54
- sendToastForError ( timeout ) ;
54
+ sendErrorToastDebounced ( timeout ) ;
55
55
} ) ;
56
56
57
57
socket . on ( 'disconnect' , ( reason : string ) => {
58
58
if ( reason === 'io server disconnect' ) {
59
- sendToastForError (
59
+ sendErrorToastDebounced (
60
60
'Websocket was disconnected due to authentication issue. Please try to refresh the page.'
61
61
) ;
62
- } else {
63
- sendToastForError (
62
+ } else if ( reason !== 'io client disconnect' ) {
63
+ sendErrorToastDebounced (
64
64
`Websocket was disconnected due to: ${ reason } `
65
65
) ;
66
66
}
0 commit comments