Skip to content

Commit

Permalink
Remove unnecessary await if we can return the promise (#50329)
Browse files Browse the repository at this point in the history
  • Loading branch information
John Schulz authored Nov 14, 2019
1 parent c522886 commit 1f6b520
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
12 changes: 3 additions & 9 deletions x-pack/legacy/plugins/integrations_manager/public/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@ export function setClient(client: HttpHandler): void {

export async function getCategories(): Promise<CategorySummaryList> {
const path = getCategoriesPath();
const list: CategorySummaryList = await _fetch(path);

return list;
return _fetch(path);
}

export async function getPackages(params?: ListParams): Promise<PackageList> {
const path = getListPath();
const options = params ? { query: { ...params } } : undefined;
const list: PackageList = await _fetch(path, options);

return list;
return _fetch(path, options);
}

export async function getPackagesGroupedByStatus() {
Expand All @@ -66,9 +62,7 @@ export async function getPackagesGroupedByStatus() {

export async function getPackageInfoByKey(pkgkey: string): Promise<PackageInfo> {
const path = getInfoPath(pkgkey);
const info: PackageInfo = await _fetch(path);

return info;
return _fetch(path);
}

export async function installPackage(pkgkey: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,16 @@ export async function handleGetCategories(req: Request, extra: Extra) {

export async function handleGetList(req: ListPackagesRequest, extra: Extra) {
const savedObjectsClient = getClient(req);
const packageList = await getPackages({
return getPackages({
savedObjectsClient,
category: req.query.category,
});

return packageList;
}

export async function handleGetInfo(req: PackageInfoRequest, extra: Extra) {
const { pkgkey } = req.params;
const savedObjectsClient = getClient(req);
const packageInfo = await getPackageInfo({ savedObjectsClient, pkgkey });

return packageInfo;
return getPackageInfo({ savedObjectsClient, pkgkey });
}

export const handleGetFile = async (req: Request, extra: Extra) => {
Expand All @@ -79,7 +75,7 @@ export const handleGetFile = async (req: Request, extra: Extra) => {
export async function handleRequestInstall(req: InstallDeletePackageRequest, extra: Extra) {
const { pkgkey } = req.params;
const savedObjectsClient = getClient(req);
return await installPackage({
return installPackage({
savedObjectsClient,
pkgkey,
});
Expand All @@ -89,7 +85,5 @@ export async function handleRequestDelete(req: InstallDeletePackageRequest, extr
const { pkgkey } = req.params;
const savedObjectsClient = getClient(req);
const callCluster = getClusterAccessor(extra.context.esClient, req);
const deleted = await removeInstallation({ savedObjectsClient, pkgkey, callCluster });

return deleted;
return removeInstallation({ savedObjectsClient, pkgkey, callCluster });
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,12 @@ export async function saveInstallationReferences(options: {
};

const toInstall = toSave.reduce(mergeRefsReducer, savedRefs || []);
const results = await savedObjectsClient.create<InstallationAttributes>(

return savedObjectsClient.create<InstallationAttributes>(
SAVED_OBJECT_TYPE,
{ installed: toInstall },
{ id: pkgkey, overwrite: true }
);

return results;
}

async function installKibanaSavedObjects({
Expand Down

0 comments on commit 1f6b520

Please sign in to comment.