提交 ec572b1d 编写于 作者: R Ramya Achutha Rao

Sort extension based recommendations based on recommended date #34233

上级 3a031832
......@@ -107,7 +107,10 @@ export class ExtensionTipsService implements IExtensionTipsService {
getRecommendations(): string[] {
const allRecomendations = this._getAllRecommendationsInProduct();
const fileBased = Object.keys(this._fileBasedRecommendations)
.filter(recommendation => allRecomendations.indexOf(recommendation) !== -1);
.filter(recommendation => allRecomendations.indexOf(recommendation) !== -1)
.sort((a, b) => {
return this._fileBasedRecommendations[a] > this._fileBasedRecommendations[b] ? -1 : 1;
});
const exeBased = distinct(this._exeBasedRecommendations);
......
......@@ -299,7 +299,10 @@ export class ExtensionsListView extends CollapsibleView {
}
options.source = 'recommendations-all';
return this.extensionsWorkbenchService.queryGallery(assign(options, { names, pageSize: names.length }))
.then(pager => new PagedModel(pager || []));
.then(pager => {
this.sortFirstPage(pager, names);
return new PagedModel(pager || []);
});
});
});
}
......@@ -321,7 +324,10 @@ export class ExtensionsListView extends CollapsibleView {
}
options.source = 'recommendations';
return this.extensionsWorkbenchService.queryGallery(assign(options, { names, pageSize: names.length }))
.then(pager => new PagedModel(pager || []));
.then(pager => {
this.sortFirstPage(pager, names);
return new PagedModel(pager || []);
});
});
}
......@@ -355,6 +361,21 @@ export class ExtensionsListView extends CollapsibleView {
.then(result => new PagedModel(result));
}
// Sorts the firsPage of the pager in the same order as given array of extension ids
private sortFirstPage(pager: IPager<IExtension>, ids: string[]) {
if (ids.length === pager.pageSize) {
let newArray = new Array(pager.pageSize);
for (let i = 0; i < pager.pageSize; i++) {
let index = ids.indexOf(pager.firstPage[i].id);
if (index === -1) {
return;
}
newArray[index] = pager.firstPage[i];
}
pager.firstPage = newArray;
}
}
private setModel(model: IPagedModel<IExtension>) {
this.list.model = model;
this.list.scrollTop = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册