@@ -154,34 +154,37 @@ export const spectaOpener: JupyterFrontEndPlugin<void, ILabShell> = {
154154 app . shell . add ( browser , 'main' , { rank : 100 } ) ;
155155 hideAppLoadingIndicator ( ) ;
156156 } else {
157- if ( PathExt . extname ( path ) === '.ipynb' ) {
158- app . shell . addClass ( 'specta-document-viewer' ) ;
159- const widget = docManager . openOrReveal ( path , 'specta' ) ;
160- if ( widget ) {
161- app . shell . add ( widget , 'main' ) ;
162- }
163- } else {
164- let count = 0 ;
165- const tryOpen = ( ) => {
166- const widget = docManager . openOrReveal ( path , 'default' ) ;
157+ app . restored . then ( async ( ) => {
158+ await new Promise ( r => setTimeout ( r , 200 ) ) ;
159+ if ( PathExt . extname ( path ) === '.ipynb' ) {
160+ app . shell . addClass ( 'specta-document-viewer' ) ;
161+ const widget = docManager . openOrReveal ( path , 'specta' ) ;
167162 if ( widget ) {
168163 app . shell . add ( widget , 'main' ) ;
169- hideAppLoadingIndicator ( ) ;
170- } else {
171- count ++ ;
172- if ( count > 10 ) {
173- console . error ( 'Failed to open file' , path ) ;
174- const widget = new Widget ( ) ;
175- widget . node . innerHTML = `<h2 style="text-align: center; margin-top: 200px;">Failed to open file ${ path } </h2>` ;
164+ }
165+ } else {
166+ let count = 0 ;
167+ const tryOpen = ( ) => {
168+ const widget = docManager . openOrReveal ( path , 'default' ) ;
169+ if ( widget ) {
176170 app . shell . add ( widget , 'main' ) ;
177171 hideAppLoadingIndicator ( ) ;
178- return ;
172+ } else {
173+ count ++ ;
174+ if ( count > 10 ) {
175+ console . error ( 'Failed to open file' , path ) ;
176+ const widget = new Widget ( ) ;
177+ widget . node . innerHTML = `<h2 style="text-align: center; margin-top: 200px;">Failed to open file ${ path } </h2>` ;
178+ app . shell . add ( widget , 'main' ) ;
179+ hideAppLoadingIndicator ( ) ;
180+ return ;
181+ }
182+ setTimeout ( tryOpen , 100 ) ;
179183 }
180- setTimeout ( tryOpen , 100 ) ;
181- }
182- } ;
183- tryOpen ( ) ;
184- }
184+ } ;
185+ tryOpen ( ) ;
186+ }
187+ } ) ;
185188 }
186189 }
187190 }
0 commit comments