@@ -17,6 +17,7 @@ import {
17
17
} from '../../browser/utils/constants' ;
18
18
import * as monaco from '@theia/monaco-editor-core' ;
19
19
import { Deferred } from '@theia/core/lib/common/promise-util' ;
20
+ import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state' ;
20
21
21
22
const READ_ONLY_FILES = [ 'sketch.json' ] ;
22
23
const READ_ONLY_FILES_REMOTE = [ 'thingProperties.h' , 'thingsProperties.h' ] ;
@@ -47,6 +48,9 @@ export class SketchesServiceClientImpl
47
48
@inject ( ConfigService )
48
49
protected readonly configService : ConfigService ;
49
50
51
+ @inject ( FrontendApplicationStateService )
52
+ private readonly appStateService : FrontendApplicationStateService ;
53
+
50
54
protected sketches = new Map < string , SketchRef > ( ) ;
51
55
// TODO: rename this + event to the `onBlabla` pattern
52
56
protected sketchbookDidChangeEmitter = new Emitter < {
@@ -117,12 +121,14 @@ export class SketchesServiceClientImpl
117
121
) ;
118
122
} ) ;
119
123
} ) ;
120
- setTimeout ( async ( ) => {
121
- const currentSketch = await this . loadCurrentSketch ( ) ;
122
- this . _currentSketch = currentSketch ;
123
- this . currentSketchDidChangeEmitter . fire ( this . _currentSketch ) ;
124
- this . currentSketchLoaded . resolve ( this . _currentSketch ) ;
125
- } , 1_000 ) ;
124
+ this . appStateService
125
+ . reachedState ( 'started_contributions' )
126
+ . then ( async ( ) => {
127
+ const currentSketch = await this . loadCurrentSketch ( ) ;
128
+ this . _currentSketch = currentSketch ;
129
+ this . currentSketchDidChangeEmitter . fire ( this . _currentSketch ) ;
130
+ this . currentSketchLoaded . resolve ( this . _currentSketch ) ;
131
+ } ) ;
126
132
}
127
133
128
134
onStop ( ) : void {
0 commit comments