Skip to content

Commit 71d033b

Browse files
artlowelalexandrevryghem
authored andcommitted
decrease the number of unnecessary rerenders by checking whether the relationship types have changed
(cherry picked from commit a658bf4)
1 parent 5f74c29 commit 71d033b

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/app/item-page/edit-item-page/item-relationships/item-relationships.component.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ import {
2020
BehaviorSubject,
2121
Observable,
2222
} from 'rxjs';
23-
import { map } from 'rxjs/operators';
23+
import {
24+
distinctUntilChanged,
25+
map,
26+
} from 'rxjs/operators';
2427

2528
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
2629
import { EntityTypeDataService } from '../../../core/data/entity-type-data.service';
@@ -40,6 +43,7 @@ import { ThemedLoadingComponent } from '../../../shared/loading/themed-loading.c
4043
import { NotificationsService } from '../../../shared/notifications/notifications.service';
4144
import { followLink } from '../../../shared/utils/follow-link-config.model';
4245
import { VarDirective } from '../../../shared/utils/var.directive';
46+
import { compareArraysUsingIds } from '../../simple/item-types/shared/item-relationships-utils';
4347
import { AbstractItemUpdateComponent } from '../abstract-item-update/abstract-item-update.component';
4448
import { EditItemRelationshipsService } from './edit-item-relationships.service';
4549
import { EditRelationshipListComponent } from './edit-relationship-list/edit-relationship-list.component';
@@ -105,10 +109,10 @@ export class ItemRelationshipsComponent extends AbstractItemUpdateComponent {
105109

106110
const label = this.item.firstMetadataValue('dspace.entity.type');
107111
if (label !== undefined) {
108-
this.relationshipTypes$ = this.relationshipTypeService.searchByEntityType(label, true, true, ...this.getRelationshipTypeFollowLinks())
109-
.pipe(
110-
map((relationshipTypes: PaginatedList<RelationshipType>) => relationshipTypes.page),
111-
);
112+
this.relationshipTypes$ = this.relationshipTypeService.searchByEntityType(label, true, true, ...this.getRelationshipTypeFollowLinks()).pipe(
113+
map((relationshipTypes: PaginatedList<RelationshipType>) => relationshipTypes.page),
114+
distinctUntilChanged(compareArraysUsingIds()),
115+
);
112116

113117
this.entityTypeService.getEntityTypeByLabel(label).pipe(
114118
getFirstSucceededRemoteData(),

0 commit comments

Comments
 (0)