Skip to content

Commit

Permalink
chore: improve logic
Browse files Browse the repository at this point in the history
  • Loading branch information
slavik-lvovsky committed Jun 14, 2021
1 parent 3fe1b02 commit 9278fdc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions packages/backend/src/panels/AbstractWebviewPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export abstract class AbstractWebviewPanel {
protected isInBAS: boolean;
protected rpc: RpcExtension;

public loadWebviewPanel(uiOptions?: any) {
public async loadWebviewPanel(uiOptions?: unknown): Promise<void> {
this.disposeWebviewPanel();
const webViewPanel = this.createWebviewPanel();
this.setWebviewPanel(webViewPanel, uiOptions);
await this.setWebviewPanel(webViewPanel, uiOptions);
}

protected constructor(context: Partial<vscode.ExtensionContext>) {
Expand All @@ -38,9 +38,10 @@ export abstract class AbstractWebviewPanel {
this.isInBAS = !_.isEmpty(_.get(process, "env.WS_BASE_URL"));
}

public setWebviewPanel(webviewPanel: vscode.WebviewPanel, state?: unknown) {
public setWebviewPanel(webviewPanel: vscode.WebviewPanel, state?: unknown): Promise<void> {
this.webViewPanel = webviewPanel;
this.state = state;
return;
}

public createWebviewPanel(): vscode.WebviewPanel {
Expand Down
6 changes: 3 additions & 3 deletions packages/backend/src/panels/ExploreGensPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import _ = require("lodash");

export class ExploreGensPanel extends AbstractWebviewPanel {
public async setWebviewPanel(webviewPanel: vscode.WebviewPanel, uiOptions?: any) {
super.setWebviewPanel(webviewPanel);
await super.setWebviewPanel(webviewPanel);
this.rpc = new RpcExtension(webviewPanel.webview, getWebviewRpcLibraryLogger());
this.exploreGens.init(this.rpc);
this.initWebviewPanel();
Expand All @@ -29,11 +29,11 @@ export class ExploreGensPanel extends AbstractWebviewPanel {
this.exploreGens = new ExploreGens(this.logger, this.isInBAS, this.context);
}

public loadWebviewPanel(uiOptions?: any) {
public async loadWebviewPanel(uiOptions?: any) {
if (this.webViewPanel && _.isNil(uiOptions)) {
this.webViewPanel.reveal();
} else {
super.loadWebviewPanel(uiOptions);
await super.loadWebviewPanel(uiOptions);
}
}
}
6 changes: 3 additions & 3 deletions packages/backend/src/panels/YeomanUIPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class YeomanUIPanel extends AbstractWebviewPanel {
}
}

super.loadWebviewPanel(uiOptions);
await super.loadWebviewPanel(uiOptions);

return this.yoUiCommandPromise;
}
Expand All @@ -87,10 +87,10 @@ export class YeomanUIPanel extends AbstractWebviewPanel {
}
}

public setWebviewPanel(webViewPanel: vscode.WebviewPanel, uiOptions?: unknown) {
public async setWebviewPanel(webViewPanel: vscode.WebviewPanel, uiOptions?: unknown): Promise<void> {
this.setYoUiPromises();

super.setWebviewPanel(webViewPanel);
await super.setWebviewPanel(webViewPanel);

this.messages = _.assign({}, backendMessages, _.get(uiOptions, "messages", {}));
const filter = GeneratorFilter.create(_.get(uiOptions, "filter"));
Expand Down

0 comments on commit 9278fdc

Please sign in to comment.