fix(ui): my applications doesnt show all applications
We need to query the applications with 2 different requests (viewable/editable).
Since switchMap() cancles previous requests it could happen that some applications wouldnt appear in the list.
Changed it to forkJoin to receive all clients at once.
MODIFY
src/app/components/my-apps/my-apps.component.ts
src/app/components/my-apps/my-apps.component.ts
@@ -35,7 +35,7 @@ import {
import { IContractExt } from '../../interfaces/IContractExt';
import { PolicyService } from '../../services/policy/policy.service';
import { catchError, map, switchMap } from 'rxjs/operators';
-import { merge, EMPTY, forkJoin } from 'rxjs';
+import { EMPTY, forkJoin, of } from 'rxjs';
import { flatArray } from '../../shared/utility';
import { SpinnerService } from '../../services/spinner/spinner.service';
import { ApiService } from '../../services/api/api.service';
@@ -89,13 +89,19 @@ export class MyAppsComponent implements OnInit {
this.spinnerService.startWaiting();
this.contractsLoaded = false;
- merge(this.backend.getEditableClients(), this.backend.getViewableClients())
+ forkJoin([
+ this.backend.getEditableClients(),
+ this.backend.getViewableClients()
+ ])
.pipe(
+ switchMap((clientSummaries: IClientSummary[][]) => {
+ return of(MyAppsComponent.getUniqueClients(clientSummaries));
+ }),
switchMap((clientSummaries: IClientSummary[]) => {
if (clientSummaries.length === 0) {
this.stopMainRequest();
}
-
+ console.log(clientSummaries);
return forkJoin(
clientSummaries.map((clientSummary) => {
return this.backend.getClientVersions(
@@ -194,6 +200,18 @@ export class MyAppsComponent implements OnInit {
});
}
+ private static getUniqueClients(clientSummaries: IClientSummary[][]) {
+ const clients: IClientSummary[] = flatArray(
+ clientSummaries
+ ) as IClientSummary[];
+
+ return [
+ ...new Map(
+ clients.map((clientSummary) => [clientSummary.id, clientSummary])
+ ).values()
+ ];
+ }
+
private fetchPolicyProbes() {
this.contracts.forEach((contract: IContractExt) => {
contract.policies.forEach((policy: IPolicyExt) => {

fix(ui): my applications doesnt show all applications

We need to query the applications with 2 different requests (viewable/editable).
Since switchMap() cancles previous requests it could happen that some applications wouldnt appear in the list.
Changed it to forkJoin to receive all clients at once.