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

This commit is contained in:
Art Lowel
2024-05-09 15:25:37 +02:00
parent 4541788a34
commit a658bf4531
2 changed files with 11 additions and 17 deletions

View File

@@ -347,7 +347,7 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
);
}),
take(1)
)
);
} else {
return EMPTY;
}
@@ -355,7 +355,7 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
toArray(),
).subscribe({
complete: () => {
this.editItemRelationshipsService.submit(this.item, this.url)
this.editItemRelationshipsService.submit(this.item, this.url);
this.submitModal.emit();
}
});

View File

@@ -1,14 +1,13 @@
import { ChangeDetectorRef, Component } from '@angular/core';
import { Item } from '../../../core/shared/item.model';
import {
DeleteRelationship,
RelationshipIdentifiable,
} from '../../../core/data/object-updates/object-updates.reducer';
import { map, switchMap, take, concatMap, toArray, tap } from 'rxjs/operators';
map,
distinctUntilChanged
} from 'rxjs/operators';
import {
combineLatest as observableCombineLatest,
Observable,
BehaviorSubject, EMPTY
BehaviorSubject
} from 'rxjs';
import { followLink } from '../../../shared/utils/follow-link-config.model';
import { AbstractItemUpdateComponent } from '../abstract-item-update/abstract-item-update.component';
@@ -18,23 +17,17 @@ import { ActivatedRoute, Router } from '@angular/router';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core';
import { RelationshipDataService } from '../../../core/data/relationship-data.service';
import { RemoteData } from '../../../core/data/remote-data';
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
import { getFirstSucceededRemoteData, getRemoteDataPayload } from '../../../core/shared/operators';
import { RequestService } from '../../../core/data/request.service';
import { RelationshipType } from '../../../core/shared/item-relationships/relationship-type.model';
import { ItemType } from '../../../core/shared/item-relationships/item-type.model';
import { EntityTypeDataService } from '../../../core/data/entity-type-data.service';
import { Relationship } from '../../../core/shared/item-relationships/relationship.model';
import { NoContent } from '../../../core/shared/NoContent.model';
import { hasValue } from '../../../shared/empty.util';
import { FieldUpdate } from '../../../core/data/object-updates/field-update.model';
import { FieldUpdates } from '../../../core/data/object-updates/field-updates.model';
import { FieldChangeType } from '../../../core/data/object-updates/field-change-type.model';
import { RelationshipTypeDataService } from '../../../core/data/relationship-type-data.service';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { EditItemRelationshipsService } from './edit-item-relationships.service';
import { compareArraysUsingIds } from '../../simple/item-types/shared/item-relationships-utils';
@Component({
selector: 'ds-item-relationships',
@@ -89,7 +82,8 @@ export class ItemRelationshipsComponent extends AbstractItemUpdateComponent {
if (label !== undefined) {
this.relationshipTypes$ = this.relationshipTypeService.searchByEntityType(label, true, true, ...this.getRelationshipTypeFollowLinks())
.pipe(
map((relationshipTypes: PaginatedList<RelationshipType>) => relationshipTypes.page)
map((relationshipTypes: PaginatedList<RelationshipType>) => relationshipTypes.page),
distinctUntilChanged(compareArraysUsingIds())
);
this.entityTypeService.getEntityTypeByLabel(label).pipe(