Skip to content

Commit

Permalink
fix: 350 bug delete node or trainrunsections cause low performance (#351
Browse files Browse the repository at this point in the history
)

* fix: performance issue fixed

* fix: performance issue fixed
  • Loading branch information
aiAdrian authored Nov 14, 2024
1 parent 721876e commit 72f8599
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/app/services/data/trainrunsection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,31 +814,46 @@ export class TrainrunSectionService implements OnDestroy {
this.operation.emit(new TrainrunOperation(OperationType.update, trainrunSection.getTrainrun()));
}

deleteListOfTrainrunSections(trainrunSections: TrainrunSection[]) {
deleteListOfTrainrunSections(trainrunSections: TrainrunSection[], enforceUpdate = true) {
trainrunSections.forEach((trainrunSection) => {
this.deleteTrainrunSectionAndCleanupNodes(trainrunSection);
this.deleteTrainrunSectionAndCleanupNodes(trainrunSection, false);
});
this.trainrunSectionsUpdated();
if (enforceUpdate) {
this.nodeService.transitionsUpdated();
this.nodeService.connectionsUpdated();
this.trainrunService.trainrunsUpdated();
this.trainrunSectionsUpdated();
}
}

deleteAllVisibleTrainrunSections() {
deleteAllVisibleTrainrunSections(enforceUpdate = true) {
const allTrainrunSections = this.trainrunSectionsStore.trainrunSections;
allTrainrunSections.forEach((trainrunSection: TrainrunSection) => {
if (this.filterService.filterTrainrunsection(trainrunSection)) {
this.deleteTrainrunSectionAndCleanupNodes(trainrunSection);
this.deleteTrainrunSectionAndCleanupNodes(trainrunSection, false);
}
});
this.trainrunSectionsUpdated();
if (enforceUpdate){
this.nodeService.transitionsUpdated();
this.nodeService.connectionsUpdated();
this.trainrunService.trainrunsUpdated();
this.trainrunSectionsUpdated();
}
}

deleteAllNonVisibleTrainrunSections() {
deleteAllNonVisibleTrainrunSections(enforceUpdate = true) {
const allTrainrunSections = this.trainrunSectionsStore.trainrunSections;
allTrainrunSections.forEach((trainrunSection: TrainrunSection) => {
if (!this.filterService.filterTrainrunsection(trainrunSection)) {
this.deleteTrainrunSectionAndCleanupNodes(trainrunSection);
this.deleteTrainrunSectionAndCleanupNodes(trainrunSection, false);
}
});
this.trainrunSectionsUpdated();
if (enforceUpdate) {
this.nodeService.transitionsUpdated();
this.nodeService.connectionsUpdated();
this.trainrunService.trainrunsUpdated();
this.trainrunSectionsUpdated();
}
}

deleteTrainrunSection(trainrunSectionId: number, enforceUpdate = true) {
Expand Down

0 comments on commit 72f8599

Please sign in to comment.