1
0

55946: Prevent list update from calling mapper over and over

This commit is contained in:
Kristof De Langhe
2018-12-20 16:11:25 +01:00
parent 1f19324ff6
commit f2bfdbcf84

View File

@@ -116,11 +116,13 @@ export class ItemCollectionMapperComponent implements OnInit {
const itemIdAndExcludingIds$ = observableCombineLatest( const itemIdAndExcludingIds$ = observableCombineLatest(
this.itemRD$.pipe( this.itemRD$.pipe(
getSucceededRemoteData(), getSucceededRemoteData(),
take(1),
map((rd: RemoteData<Item>) => rd.payload), map((rd: RemoteData<Item>) => rd.payload),
map((item: Item) => item.id) map((item: Item) => item.id)
), ),
this.itemCollectionsRD$.pipe( this.itemCollectionsRD$.pipe(
getSucceededRemoteData(), getSucceededRemoteData(),
take(1),
map((rd: RemoteData<PaginatedList<Collection>>) => rd.payload.page), map((rd: RemoteData<PaginatedList<Collection>>) => rd.payload.page),
map((collections: Collection[]) => collections.map((collection: Collection) => collection.id)) map((collections: Collection[]) => collections.map((collection: Collection) => collection.id))
) )
@@ -168,6 +170,7 @@ export class ItemCollectionMapperComponent implements OnInit {
*/ */
private showNotifications(responses$: Observable<RestResponse[]>, messagePrefix: string) { private showNotifications(responses$: Observable<RestResponse[]>, messagePrefix: string) {
responses$.subscribe((responses: RestResponse[]) => { responses$.subscribe((responses: RestResponse[]) => {
console.log('message ' + messagePrefix + ' for ' + responses.length + ' responses...');
const successful = responses.filter((response: RestResponse) => response.isSuccessful); const successful = responses.filter((response: RestResponse) => response.isSuccessful);
const unsuccessful = responses.filter((response: RestResponse) => !response.isSuccessful); const unsuccessful = responses.filter((response: RestResponse) => !response.isSuccessful);
if (successful.length > 0) { if (successful.length > 0) {