File tree Expand file tree Collapse file tree
packages/pluggableWidgets/pusher-web/src/hooks Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,20 +12,21 @@ export function usePusherSubscribe(subscription?: SubscriptionConfig): void {
1212
1313 useEffect ( ( ) => {
1414 const controller = new AbortController ( ) ;
15- let instance : PusherListener | null = null ;
15+ let listenerInstance : PusherListener | null = null ;
1616
1717 createPusherListener ( controller . signal ) . then ( result => {
1818 if ( controller . signal . aborted ) {
1919 result ?. destroy ( ) ;
2020 return ;
2121 }
22- instance = result ;
23- setListener ( result ) ;
22+ listenerInstance = result ;
23+
24+ setListener ( listenerInstance ) ;
2425 } ) ;
2526
2627 return ( ) => {
2728 controller . abort ( ) ;
28- instance ?. destroy ( ) ;
29+ listenerInstance ?. destroy ( ) ;
2930 setListener ( null ) ;
3031 } ;
3132 } , [ ] ) ;
@@ -34,14 +35,11 @@ export function usePusherSubscribe(subscription?: SubscriptionConfig): void {
3435 if ( ! listener ) {
3536 return ;
3637 }
38+
3739 if ( ! subscription ) {
3840 listener . unsubscribe ( ) ;
39- return ;
41+ } else {
42+ listener . subscribe ( subscription ) ;
4043 }
41-
42- listener . subscribe ( subscription ) ;
43- return ( ) => {
44- listener . unsubscribe ( ) ;
45- } ;
4644 } , [ listener , subscription ] ) ;
4745}
You can’t perform that action at this time.
0 commit comments