Skip to content
This repository has been archived by the owner on Apr 26, 2020. It is now read-only.

Commit

Permalink
fix: online store does not query version
Browse files Browse the repository at this point in the history
Change-Id: I2668425386a545e240a90b98d3304352d997b160
  • Loading branch information
myml committed Nov 2, 2018
1 parent 3f0d504 commit b05fbe2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
17 changes: 10 additions & 7 deletions src/web/src/app/components/app-list/app-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,16 @@ export class AppListComponent implements OnInit, OnChanges, OnDestroy {
if (this.maxCount) {
apps = apps.slice(0, this.maxCount);
}
const versionMap = await this.storeService
.getVersionMap(apps.map(app => app.name))
.toPromise();
apps = apps.filter(app => versionMap.has(app.name)).map(app => {
app.version = versionMap.get(app.name);
return app;
});

if (BaseService.isNative) {
const versionMap = await this.storeService
.getVersionMap(apps.map(app => app.name))
.toPromise();
apps = apps.filter(app => versionMap.has(app.name)).map(app => {
app.version = versionMap.get(app.name);
return app;
});
}

this.apps = apps;
this.appListLength.emit(this.apps.length);
Expand Down
2 changes: 0 additions & 2 deletions src/web/src/app/dstore-client.module/utils/dstore-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ export class DstoreObject {
}
static openOnlineImage(): Observable<string> {
return new Observable<string>(obs => {
console.log('openOnlineImage');
const openOnlineImage: Signal = get(window, [
...DstoreObjectPath,
'imageViewer',
'openOnlineImageRequest',
]);
console.log(openOnlineImage, [...DstoreObjectPath, 'imageViewer', 'openOnlineImageRequest']);
if (openOnlineImage) {
const callback = (src: string) => obs.next(src);
openOnlineImage.connect(callback);
Expand Down
11 changes: 7 additions & 4 deletions src/web/src/app/dstore/components/ranking/ranking.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,13 @@ export class RankingComponent implements OnInit, OnDestroy {
apps = apps.filter(app => app.category === category);
}
apps.sort((a, b) => b.downloads - a.downloads).slice(0, this.section.ranking.count);
const versionMap = await this.storeService
.getVersionMap(apps.map(app => app.name))
.toPromise();
this.appList = apps.filter(app => versionMap.has(app.name));
if (BaseService.isNative) {
const versionMap = await this.storeService
.getVersionMap(apps.map(app => app.name))
.toPromise();
apps = apps.filter(app => versionMap.has(app.name));
}
this.appList = apps;
this.getJobs();
});
}
Expand Down
8 changes: 8 additions & 0 deletions src/web/src/app/services/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class AppService {
private appStatService: AppStatService,
private storeService: StoreService,
) {}
private native = Boolean(window['dstore']);
private server = BaseService.serverHosts.operationServer;
activeList = this.http.get<{ apps: string[] }>(`${this.server}/api/app`).toPromise();

Expand Down Expand Up @@ -56,6 +57,13 @@ export class AppService {
return this.list().pipe(map(apps => apps.filter(app => app.category === category)));
}
getApps(appNameList: string[]): Observable<App[]> {
if (!this.native) {
return this.getAppMap().pipe(
map(appMap => {
return appNameList.map(name => appMap.get(name)).filter(Boolean);
}),
);
}
return combineLatest(this.getAppMap(), this.storeService.getVersionMap(appNameList)).pipe(
map(([appMap, versionMap]) => {
const apps = appNameList
Expand Down

0 comments on commit b05fbe2

Please sign in to comment.