Skip to content

Commit

Permalink
decrease the number of unnecessary rerenders by checking whether the …
Browse files Browse the repository at this point in the history
…relationship types have changed

(cherry picked from commit a658bf4)
  • Loading branch information
artlowel authored and alexandrevryghem committed May 16, 2024
1 parent 5f74c29 commit 71d033b
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import {
BehaviorSubject,
Observable,
} from 'rxjs';
import { map } from 'rxjs/operators';
import {
distinctUntilChanged,
map,
} from 'rxjs/operators';

import { ObjectCacheService } from '../../../core/cache/object-cache.service';
import { EntityTypeDataService } from '../../../core/data/entity-type-data.service';
Expand All @@ -40,6 +43,7 @@ import { ThemedLoadingComponent } from '../../../shared/loading/themed-loading.c
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { followLink } from '../../../shared/utils/follow-link-config.model';
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 { EditItemRelationshipsService } from './edit-item-relationships.service';
import { EditRelationshipListComponent } from './edit-relationship-list/edit-relationship-list.component';
Expand Down Expand Up @@ -105,10 +109,10 @@ export class ItemRelationshipsComponent extends AbstractItemUpdateComponent {

const label = this.item.firstMetadataValue('dspace.entity.type');
if (label !== undefined) {
this.relationshipTypes$ = this.relationshipTypeService.searchByEntityType(label, true, true, ...this.getRelationshipTypeFollowLinks())
.pipe(
map((relationshipTypes: PaginatedList<RelationshipType>) => relationshipTypes.page),
);
this.relationshipTypes$ = this.relationshipTypeService.searchByEntityType(label, true, true, ...this.getRelationshipTypeFollowLinks()).pipe(
map((relationshipTypes: PaginatedList<RelationshipType>) => relationshipTypes.page),
distinctUntilChanged(compareArraysUsingIds()),
);

this.entityTypeService.getEntityTypeByLabel(label).pipe(
getFirstSucceededRemoteData(),
Expand Down

0 comments on commit 71d033b

Please sign in to comment.