@@ -54,6 +54,17 @@ export const reconnectReload = () => {
5454 }
5555}
5656
57+ export const quickDevReconnect = ( ) => {
58+ if ( ! lastConnectOptions . value ) {
59+ return
60+ }
61+
62+ resetAppStatusState ( )
63+ window . dispatchEvent ( new window . CustomEvent ( 'connect' , {
64+ detail : lastConnectOptions . value
65+ } ) )
66+ }
67+
5768export default ( ) => {
5869 const lastState = useRef ( JSON . parse ( JSON . stringify ( appStatusState ) ) )
5970 const currentState = useSnapshot ( appStatusState )
@@ -105,21 +116,14 @@ export default () => {
105116 }
106117 } , [ isOpen ] )
107118
108- const reconnect = ( ) => {
109- resetAppStatusState ( )
110- window . dispatchEvent ( new window . CustomEvent ( 'connect' , {
111- detail : lastConnectOptions . value
112- } ) )
113- }
114-
115119 useEffect ( ( ) => {
116120 const controller = new AbortController ( )
117121 window . addEventListener ( 'keyup' , ( e ) => {
118122 if ( 'input textarea select' . split ( ' ' ) . includes ( ( e . target as HTMLElement ) . tagName ?. toLowerCase ( ) ?? '' ) ) return
119123 if ( activeModalStack . at ( - 1 ) ?. reactType !== 'app-status' ) return
120124 // todo do only if reconnect is possible
121125 if ( e . code !== 'KeyR' || ! lastConnectOptions . value ) return
122- reconnect ( )
126+ quickDevReconnect ( )
123127 } , {
124128 signal : controller . signal
125129 } )
@@ -140,7 +144,7 @@ export default () => {
140144 const account = await showOptionsModal ( 'Choose account to connect with' , [ ...accounts . map ( account => account . username ) , 'Use other account' ] )
141145 if ( ! account ) return
142146 lastConnectOptions . value ! . authenticatedAccount = accounts . find ( acc => acc . username === account ) || true
143- reconnect ( )
147+ quickDevReconnect ( )
144148 }
145149
146150 const lastAutoCapturedPackets = getLastAutoCapturedPackets ( )
@@ -184,7 +188,7 @@ export default () => {
184188 actionsSlot = {
185189 < >
186190 { displayAuthButton && < Button label = 'Authenticate' onClick = { authReconnectAction } /> }
187- { displayVpnButton && < PossiblyVpnBypassProxyButton reconnect = { reconnect } /> }
191+ { displayVpnButton && < PossiblyVpnBypassProxyButton reconnect = { quickDevReconnect } /> }
188192 { replayActive && < Button label = { `Download Packets Replay ${ replayLogger ?. contents . split ( '\n' ) . length } L` } onClick = { downloadPacketsReplay } /> }
189193 { wasDisconnected && lastAutoCapturedPackets && < Button label = { `Inspect Last ${ lastAutoCapturedPackets } Packets` } onClick = { ( ) => downloadAutoCapturedPackets ( ) } /> }
190194 </ >
0 commit comments