aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2021-01-11 23:03:06 +0100
committerMartin Stockhammer <martin_s@apache.org>2021-01-11 23:03:06 +0100
commitcc1c52b3d49dccd52a79779601c6639916d86339 (patch)
tree2708580b0b0010ab879ae6729720f9de86419162 /archiva-modules
parent255fc64b520e1d2c3a925e53c515301676ae03ed (diff)
downloadarchiva-cc1c52b3d49dccd52a79779601c6639916d86339.tar.gz
archiva-cc1c52b3d49dccd52a79779601c6639916d86339.zip
Fixing multiple REST calls
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/paginated-entities/paginated-entities.component.ts20
1 files changed, 17 insertions, 3 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/paginated-entities/paginated-entities.component.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/paginated-entities/paginated-entities.component.ts
index f7d2188a8..6239e88d2 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/paginated-entities/paginated-entities.component.ts
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/paginated-entities/paginated-entities.component.ts
@@ -18,7 +18,17 @@
import {AfterViewInit, Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {concat, merge, Observable, of, Subject} from "rxjs";
-import {debounceTime, distinctUntilChanged, filter, map, pluck, startWith, switchMap} from "rxjs/operators";
+import {
+ debounceTime,
+ distinctUntilChanged,
+ filter,
+ map,
+ multicast,
+ pluck,
+ refCount,
+ startWith,
+ switchMap
+} from "rxjs/operators";
import {EntityService} from "@app/model/entity-service";
import {FieldToggle} from "@app/model/field-toggle";
import {PageQuery} from "../model/page-query";
@@ -151,7 +161,7 @@ export class PaginatedEntitiesComponent<T> implements OnInit, FieldToggle, After
}
ngOnInit(): void {
- // console.log("Pag Init " + this.id);
+ console.log("Pag Init " + this.id);
// We combine the sources for the page and the search input field to a observable 'source'
const pageSource = this.pageStream.pipe(map(pageNumber => {
return new PageQuery(this.searchTerm, pageNumber);
@@ -171,7 +181,11 @@ export class PaginatedEntitiesComponent<T> implements OnInit, FieldToggle, After
this.service(params.search, (params.page - 1) * this.pageSize, this.pageSize, this.sortField, this.sortOrder)
.pipe(map(pagedResult=>LoadingValue.finish<PagedResult<T>>(pagedResult)))
)
- )
+ ),
+ // This is to avoid multiple REST calls, without each subscriber would
+ // cause a REST call.
+ multicast(new Subject()),
+ refCount()
);
this.total$ = source.pipe(filter(val=>val.hasValue()),map(val=>val.value),
pluck('pagination', 'total_count'));