@@ -170,25 +170,29 @@ class WebuiBridge {
170170 }
171171 }
172172 #freezeUi( ) {
173- if ( document . getElementById ( 'webui-error-connection-lost' ) ) return ;
174- const div = document . createElement ( 'div' ) ;
175- div . id = 'webui-error-connection-lost' ;
176- Object . assign ( div . style , {
177- position : 'relative' ,
178- top : '0' ,
179- left : '0' ,
180- width : '100%' ,
181- backgroundColor : '#ff4d4d' ,
182- color : '#fff' ,
183- textAlign : 'center' ,
184- padding : '2px 0' ,
185- fontFamily : 'Arial, sans-serif' ,
186- fontSize : '14px' ,
187- zIndex : '1000' ,
188- lineHeight : '1'
189- } ) ;
190- div . innerText = 'WebUI Error: Connection with the backend is lost.' ;
191- document . body . insertBefore ( div , document . body . firstChild ) ;
173+ setTimeout ( ( ) => {
174+ if ( ! this . #wsIsConnected( ) ) {
175+ if ( document . getElementById ( 'webui-error-connection-lost' ) ) return ;
176+ const div = document . createElement ( 'div' ) ;
177+ div . id = 'webui-error-connection-lost' ;
178+ Object . assign ( div . style , {
179+ position : 'relative' ,
180+ top : '0' ,
181+ left : '0' ,
182+ width : '100%' ,
183+ backgroundColor : '#ff4d4d' ,
184+ color : '#fff' ,
185+ textAlign : 'center' ,
186+ padding : '2px 0' ,
187+ fontFamily : 'Arial, sans-serif' ,
188+ fontSize : '14px' ,
189+ zIndex : '1000' ,
190+ lineHeight : '1'
191+ } ) ;
192+ div . innerText = 'WebUI Error: Connection with the backend is lost.' ;
193+ document . body . insertBefore ( div , document . body . firstChild ) ;
194+ }
195+ } , 1000 ) ;
192196 }
193197 #unfreezeUI( ) {
194198 const div = document . getElementById ( 'webui-error-connection-lost' ) ;
@@ -508,7 +512,7 @@ class WebuiBridge {
508512 return ( ( this . #ws) && ( this . #ws. readyState === WebSocket . OPEN ) ) ;
509513 }
510514 #wsConnect( ) : void {
511- if ( this . #ws ) {
515+ if ( this . #wsIsConnected ( ) ) {
512516 this . #ws. close ( ) ;
513517 }
514518 this . #TokenAccepted = false ;
0 commit comments