Skip to content

Commit

Permalink
fix: plugin doesn't show welcome view (eclipse-theia#12458)
Browse files Browse the repository at this point in the history
The commit check view data provider after start plugin
to show plugin welcom view.

Signed-off-by: zhangyi <1401457589@qq.com>
  • Loading branch information
helloworldmygithub committed Apr 27, 2023
1 parent 58be997 commit e5dad4e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
3 changes: 3 additions & 0 deletions packages/plugin-ext/src/hosted/browser/hosted-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ export class HostedPluginSupport {
}
await this.startPlugins(contributionsByHost, toDisconnect);

// check data provider after start plugin to show welcom view
this.viewRegistry.checkViewDataProvider();

this.deferredDidStart.resolve();

this.restoreWebviews();
Expand Down
39 changes: 34 additions & 5 deletions packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,19 +780,48 @@ export class PluginViewRegistry implements FrontendApplicationContribution {
return toDispose;
}

checkViewDataProvider(): void {
for (const viewId of this.views.keys()) {
if (!this.viewDataProviders.has(viewId)) {
this.getView(viewId).then(async view => {
if (view) {
if (view.isVisible) {
await this.prepareView(view);
} else {
const toDisposeOnDidExpandView = new DisposableCollection(this.onDidExpandView(async id => {
if (id === viewId) {
unsubscribe();
await this.prepareView(view);
}
}));
const unsubscribe = () => toDisposeOnDidExpandView.dispose();
view.disposed.connect(unsubscribe);
toDisposeOnDidExpandView.push(Disposable.create(() => view.disposed.disconnect(unsubscribe)));
}
}
});
}
}
}

protected async createViewDataWidget(viewId: string, webviewId?: string): Promise<Widget | undefined> {
const view = this.views.get(viewId);
if (view?.[1]?.type === PluginViewType.Webview) {
const webviewWidget = this.widgetManager.getWidget(WebviewWidget.FACTORY_ID, <WebviewWidgetIdentifier>{ id: webviewId });
return webviewWidget;
}
const provider = this.viewDataProviders.get(viewId);
if (!view || !provider) {
if (!view) {
return undefined;
}
const [, viewInfo] = view;
const state = this.viewDataState.get(viewId);
const widget = await provider({ state, viewInfo });
let widget;
const provider = this.viewDataProviders.get(viewId);
if (!provider) {
widget = await this.widgetManager.getOrCreateWidget<TreeViewWidget>(PLUGIN_VIEW_DATA_FACTORY_ID, { id: viewId });
} else {
const [, viewInfo] = view;
const state = this.viewDataState.get(viewId);
widget = await provider({ state, viewInfo });
}
widget.handleViewWelcomeContentChange(this.getViewWelcomes(viewId));
if (StatefulWidget.is(widget)) {
this.storeViewDataStateOnDispose(viewId, widget);
Expand Down

0 comments on commit e5dad4e

Please sign in to comment.