Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delay hosted plugins' initialization #4383

Merged
merged 2 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions packages/plugin-ext/src/hosted/browser/hosted-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ export class HostedPluginSupport {
@inject(PluginServer)
protected readonly pluginServer: PluginServer;

@inject(WorkspaceService)
protected readonly workspaceService: WorkspaceService;

@inject(PreferenceProviderProvider)
protected readonly preferenceProviderProvider: PreferenceProviderProvider;

Expand All @@ -72,8 +69,9 @@ export class HostedPluginSupport {
@inject(PreferenceServiceImpl) private readonly preferenceServiceImpl: PreferenceServiceImpl,
@inject(PluginPathsService) private readonly pluginPathsService: PluginPathsService,
@inject(StoragePathService) private readonly storagePathService: StoragePathService,
@inject(WorkspaceService) protected readonly workspaceService: WorkspaceService,
) {
this.theiaReadyPromise = Promise.all([this.preferenceServiceImpl.ready]);
this.theiaReadyPromise = Promise.all([this.preferenceServiceImpl.ready, this.workspaceService.roots]);

this.storagePathService.onStoragePathChanged(path => {
this.updateStoragePath(path);
Expand Down Expand Up @@ -154,6 +152,7 @@ export class HostedPluginSupport {
pluginID = getPluginId(plugins[0].model);
}
const rpc = this.createServerRpc(pluginID, hostKey);
setUpPluginApi(rpc, container);
const hostedExtManager = rpc.getProxy(MAIN_RPC_CONTEXT.HOSTED_PLUGIN_MANAGER_EXT);
hostedExtManager.$init({
plugins: plugins,
Expand All @@ -163,7 +162,6 @@ export class HostedPluginSupport {
env: { queryParams: getQueryParameters() },
extApi: initData.pluginAPIs
}, confStorage);
setUpPluginApi(rpc, container);
this.mainPluginApiProviders.getContributions().forEach(p => p.initialize(rpc, container));
this.backendExtManagerProxy = hostedExtManager;
});
Expand Down
7 changes: 2 additions & 5 deletions packages/plugin-ext/src/main/browser/workspace-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ export class WorkspaceMainImpl implements WorkspaceMain {

this.inPluginFileSystemWatcherManager = new InPluginFileSystemWatcherManager(this.proxy, container);

this.workspaceService.roots.then(roots => {
this.processWorkspaceFoldersChanged(roots);
});

this.processWorkspaceFoldersChanged(this.workspaceService.tryGetRoots());
this.workspaceService.onWorkspaceChanged(roots => {
this.processWorkspaceFoldersChanged(roots);
});
Expand All @@ -81,13 +78,13 @@ export class WorkspaceMainImpl implements WorkspaceMain {
return;
}
this.roots = roots;
this.proxy.$onWorkspaceFoldersChanged({ roots });

await this.storagePathService.updateStoragePath(roots);

const keyValueStorageWorkspacesData = await this.pluginServer.keyValueStorageGetAll(false);
this.storageProxy.$updatePluginsWorkspaceData(keyValueStorageWorkspacesData);

this.proxy.$onWorkspaceFoldersChanged({ roots });
}

private isAnyRootChanged(roots: FileStat[]): boolean {
Expand Down