Skip to content

Commit

Permalink
cleanup duplicated code
Browse files Browse the repository at this point in the history
This commit removes duplicated code by adding a `doInstall` protected
method.

Signed-off-by: Vlad Arama <vlad.arama@ericsson.com>
  • Loading branch information
vladarama committed Nov 14, 2023
1 parent f11f223 commit bad15a4
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions packages/vsx-registry/src/browser/vsx-extension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,24 +309,10 @@ export class VSXExtension implements VSXExtensionData, TreeElement {
msg: nls.localize('theia/vsx-registry/confirmDialogMessage', 'The extension "{0}" is unverified and might pose a security risk.', this.displayName)
}).open();
if (choice) {
this._busy++;
try {
await this.progressService.withProgress(nls.localizeByDefault("Installing extension '{0}' v{1}...", this.id, this.version ?? 0), 'extensions', () =>
this.pluginServer.deploy(this.uri.toString(), undefined, options)
);
} finally {
this._busy--;
}
this.doInstall(options);
}
} else {
this._busy++;
try {
await this.progressService.withProgress(nls.localizeByDefault("Installing extension '{0}' v{1}...", this.id, this.version ?? 0), 'extensions', () =>
this.pluginServer.deploy(this.uri.toString(), undefined, options)
);
} finally {
this._busy--;
}
this.doInstall(options);
}
}

Expand All @@ -345,6 +331,17 @@ export class VSXExtension implements VSXExtensionData, TreeElement {
}
}

protected async doInstall(options?: PluginDeployOptions): Promise<void> {
this._busy++;
try {
await this.progressService.withProgress(nls.localizeByDefault("Installing extension '{0}' v{1}...", this.id, this.version ?? 0), 'extensions', () =>
this.pluginServer.deploy(this.uri.toString(), undefined, options)
);
} finally {
this._busy--;
}
}

handleContextMenu(e: React.MouseEvent<HTMLElement, MouseEvent>): void {
e.preventDefault();
this.contextMenuRenderer.render({
Expand Down

0 comments on commit bad15a4

Please sign in to comment.