-
-
Notifications
You must be signed in to change notification settings - Fork 435
/
Copy pathfrontend-application.ts
39 lines (33 loc) · 1.48 KB
/
frontend-application.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { injectable, inject } from '@theia/core/shared/inversify';
import { CommandService } from '@theia/core/lib/common/command';
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
import { FrontendApplication as TheiaFrontendApplication } from '@theia/core/lib/browser/frontend-application';
import { SketchesService } from '../../../common/protocol';
import { OpenSketchFiles } from '../../contributions/open-sketch-files';
@injectable()
export class FrontendApplication extends TheiaFrontendApplication {
@inject(WorkspaceService)
private readonly workspaceService: WorkspaceService;
@inject(CommandService)
private readonly commandService: CommandService;
@inject(SketchesService)
private readonly sketchesService: SketchesService;
private layoutWasRestored = false;
protected override async initializeLayout(): Promise<void> {
await super.initializeLayout();
this.workspaceService.roots.then(async (roots) => {
for (const root of roots) {
await this.commandService.executeCommand(
OpenSketchFiles.Commands.OPEN_SKETCH_FILES.id,
root.resource,
!this.layoutWasRestored
);
this.sketchesService.markAsRecentlyOpened(root.resource.toString()); // no await, will get the notification later and rebuild the menu
}
});
}
protected override async restoreLayout(): Promise<boolean> {
this.layoutWasRestored = await super.restoreLayout();
return this.layoutWasRestored;
}
}