Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Commit

Permalink
made remaining methods non-async
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohlmeier committed Dec 19, 2019
1 parent 71de973 commit 8c3f200
Showing 1 changed file with 40 additions and 29 deletions.
69 changes: 40 additions & 29 deletions src/main/plugins/control-panel-plugin/control-panel-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,48 @@ export class ControlPanelPlugin implements SearchPlugin {
return this.config.isEnabled;
}

public async execute(searchResultItem: SearchResultItem, privileged: boolean): Promise<void> {
const shell = new Powershell({});
shell.addCommand(`powershell -Command "Show-ControlPanelItem -Name '${searchResultItem.executionArgument}'"`);
shell.invoke()
.catch((reason) => this.logger.error("Opening control panel item failed: " + reason))
.finally(() => shell.dispose());
public execute(searchResultItem: SearchResultItem, privileged: boolean): Promise<void> {
return new Promise((resolve) => {
const shell = new Powershell({});
shell.addCommand(`powershell -Command "Show-ControlPanelItem -Name '${searchResultItem.executionArgument}'"`)
.then(() => shell.invoke())
.catch((reason) => this.logger.error("Opening control panel item failed: " + reason))
.finally(() => shell.dispose());
resolve();
});
}

public async updateConfig(updatedConfig: UserConfigOptions, translationSet: TranslationSet): Promise<void> {
this.config = updatedConfig.controlPanelOptions;
public updateConfig(updatedConfig: UserConfigOptions, translationSet: TranslationSet): Promise<void> {
return new Promise((resolve) => {
this.config = updatedConfig.controlPanelOptions;
resolve();
});
}

public async getAll(): Promise<SearchResultItem[]> {
return this.controlPanelItems.map((item) => ({
description: item.Description,
executionArgument: item.Name,
hideMainWindowAfterExecution: true,
icon: {
parameter: item.IconBase64
? `data:image/png;base64,${item.IconBase64}`
: defaultControlPanelIcon,
type: IconType.URL,
},
name: item.Name,
needsUserConfirmationBeforeExecution: false,
originPluginType: PluginType.ControlPanel,
searchable: [item.Name, item.Description],
supportsAutocompletion: true,
supportsOpenLocation: false,
}));
public getAll(): Promise<SearchResultItem[]> {
return new Promise((resolve) => {
const searchResultItems = this.controlPanelItems.map((item) => ({
description: item.Description,
executionArgument: item.Name,
hideMainWindowAfterExecution: true,
icon: {
parameter: item.IconBase64
? `data:image/png;base64,${item.IconBase64}`
: defaultControlPanelIcon,
type: IconType.URL,
},
name: item.Name,
needsUserConfirmationBeforeExecution: false,
originPluginType: PluginType.ControlPanel,
searchable: [item.Name, item.Description],
supportsAutocompletion: true,
supportsOpenLocation: false,
}));
resolve(searchResultItems);
});
}

public async refreshIndex(): Promise<void> {
public refreshIndex(): Promise<void> {
return new Promise((resolve, reject) => {
ControlPanelItemsRetriever.RetrieveControlPanelItems(this.controlPanelItems)
.then((controlPanelItems) => {
Expand All @@ -70,7 +79,9 @@ export class ControlPanelPlugin implements SearchPlugin {
});
}

public async clearCache(): Promise<void> {
// not necessary
public clearCache(): Promise<void> {
return new Promise((resolve) => {
resolve();
});
}
}

0 comments on commit 8c3f200

Please sign in to comment.