Skip to content

Commit ee17fd4

Browse files
author
Akos Kitta
committed
no setTimeout
Signed-off-by: Akos Kitta <[email protected]>
1 parent 350c04b commit ee17fd4

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Diff for: arduino-ide-extension/src/common/protocol/sketches-service-client-impl.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
} from '../../browser/utils/constants';
1818
import * as monaco from '@theia/monaco-editor-core';
1919
import { Deferred } from '@theia/core/lib/common/promise-util';
20+
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
2021

2122
const READ_ONLY_FILES = ['sketch.json'];
2223
const READ_ONLY_FILES_REMOTE = ['thingProperties.h', 'thingsProperties.h'];
@@ -47,6 +48,9 @@ export class SketchesServiceClientImpl
4748
@inject(ConfigService)
4849
protected readonly configService: ConfigService;
4950

51+
@inject(FrontendApplicationStateService)
52+
private readonly appStateService: FrontendApplicationStateService;
53+
5054
protected sketches = new Map<string, SketchRef>();
5155
// TODO: rename this + event to the `onBlabla` pattern
5256
protected sketchbookDidChangeEmitter = new Emitter<{
@@ -117,12 +121,14 @@ export class SketchesServiceClientImpl
117121
);
118122
});
119123
});
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+
});
126132
}
127133

128134
onStop(): void {

0 commit comments

Comments
 (0)