decrease the number of unnecessary rerenders by checking whether the relationship types have changed

(cherry picked from commit a658bf4531)
This commit is contained in:
Art Lowel
2024-05-09 15:25:37 +02:00
committed by Alexandre Vryghem
parent 5f74c295d3
commit 71d033bf50

View File

@@ -20,7 +20,10 @@ import {
BehaviorSubject, BehaviorSubject,
Observable, Observable,
} from 'rxjs'; } from 'rxjs';
import { map } from 'rxjs/operators'; import {
distinctUntilChanged,
map,
} from 'rxjs/operators';
import { ObjectCacheService } from '../../../core/cache/object-cache.service'; import { ObjectCacheService } from '../../../core/cache/object-cache.service';
import { EntityTypeDataService } from '../../../core/data/entity-type-data.service'; import { EntityTypeDataService } from '../../../core/data/entity-type-data.service';
@@ -40,6 +43,7 @@ import { ThemedLoadingComponent } from '../../../shared/loading/themed-loading.c
import { NotificationsService } from '../../../shared/notifications/notifications.service'; import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { followLink } from '../../../shared/utils/follow-link-config.model'; import { followLink } from '../../../shared/utils/follow-link-config.model';
import { VarDirective } from '../../../shared/utils/var.directive'; import { VarDirective } from '../../../shared/utils/var.directive';
import { compareArraysUsingIds } from '../../simple/item-types/shared/item-relationships-utils';
import { AbstractItemUpdateComponent } from '../abstract-item-update/abstract-item-update.component'; import { AbstractItemUpdateComponent } from '../abstract-item-update/abstract-item-update.component';
import { EditItemRelationshipsService } from './edit-item-relationships.service'; import { EditItemRelationshipsService } from './edit-item-relationships.service';
import { EditRelationshipListComponent } from './edit-relationship-list/edit-relationship-list.component'; import { EditRelationshipListComponent } from './edit-relationship-list/edit-relationship-list.component';
@@ -105,10 +109,10 @@ export class ItemRelationshipsComponent extends AbstractItemUpdateComponent {
const label = this.item.firstMetadataValue('dspace.entity.type'); const label = this.item.firstMetadataValue('dspace.entity.type');
if (label !== undefined) { if (label !== undefined) {
this.relationshipTypes$ = this.relationshipTypeService.searchByEntityType(label, true, true, ...this.getRelationshipTypeFollowLinks()) this.relationshipTypes$ = this.relationshipTypeService.searchByEntityType(label, true, true, ...this.getRelationshipTypeFollowLinks()).pipe(
.pipe( map((relationshipTypes: PaginatedList<RelationshipType>) => relationshipTypes.page),
map((relationshipTypes: PaginatedList<RelationshipType>) => relationshipTypes.page), distinctUntilChanged(compareArraysUsingIds()),
); );
this.entityTypeService.getEntityTypeByLabel(label).pipe( this.entityTypeService.getEntityTypeByLabel(label).pipe(
getFirstSucceededRemoteData(), getFirstSucceededRemoteData(),