Skip to content

Commit

Permalink
[workspace] optimize slow onStart callback
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov committed Nov 7, 2018
1 parent 72847b0 commit 9b08af1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ export class WorkspaceFrontendContribution implements CommandContribution, Keybi
isEnabled: () => this.workspaceService.opened,
execute: () => this.closeWorkspace()
});
commands.registerCommand(WorkspaceCommands.OPEN_RECENT_WORKSPACE, {
isEnabled: () => this.workspaceService.hasHistory,
execute: () => this.quickOpenWorkspace.select()
this.workspaceService.recentWorkspaces().then(({ length }) => {
if (!length) {
commands.registerCommand(WorkspaceCommands.OPEN_RECENT_WORKSPACE, {
execute: () => this.quickOpenWorkspace.select()
});
}
});
commands.registerCommand(WorkspaceCommands.SAVE_WORKSPACE_AS, {
isEnabled: () => this.workspaceService.isMultiRootWorkspaceOpened,
Expand Down
13 changes: 0 additions & 13 deletions packages/workspace/src/browser/workspace-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ export class WorkspaceService implements FrontendApplicationContribution {
private _roots: FileStat[] = [];
private deferredRoots = new Deferred<FileStat[]>();

private hasWorkspace: boolean = false;

@inject(FileSystem)
protected readonly fileSystem: FileSystem;

Expand Down Expand Up @@ -193,17 +191,6 @@ export class WorkspaceService implements FrontendApplicationContribution {
this.server.setMostRecentlyUsedWorkspace(this._workspace ? this._workspace.uri : '');
}

async onStart() {
const allWorkspace = await this.recentWorkspaces();
if (allWorkspace.length > 0) {
this.hasWorkspace = true;
}
}

get hasHistory(): boolean {
return this.hasWorkspace;
}

async recentWorkspaces(): Promise<string[]> {
return this.server.getRecentWorkspaces();
}
Expand Down

0 comments on commit 9b08af1

Please sign in to comment.