Skip to content

Commit

Permalink
Update diagram.component.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
rjohnson465 committed Aug 18, 2021
1 parent 5ccd8c4 commit cee59bd
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions projects/gojs-angular/src/lib/diagram.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,28 +262,29 @@ export class DiagramComponent {

if (this.wasCleared) {
this.diagram.delayInitialization(() => {
this.mergeAppDataWithModel(this, nodeDiffs, linkDiffs, true);
this.mergeAppDataWithModel(this, true);
this.wasCleared = false;
});
} else {
this.mergeAppDataWithModel(this, nodeDiffs, linkDiffs, false);
this.mergeAppDataWithModel(this, false);
}

} // end ngDoCheck

private mergeAppDataWithModel(component: DiagramComponent, nodeDiffs, linkDiffs, isInit?: boolean) {
private mergeAppDataWithModel(component: DiagramComponent, isInit?: boolean) {

// don't need model change listener while performing known data updates
if (component.modelChangedListener !== null) this.diagram.model.removeChangedListener(this.modelChangedListener);

component.diagram.model.startTransaction('update data');
// update modelData first, in case bindings on nodes / links depend on model data
component.diagram.model.assignAllDataProperties(this.diagram.model.modelData, this.modelData);
// merge node / link data
this.diagram.model.mergeNodeDataArray(this.nodeDataArray);
if (component.linkDataArray && component.diagram.model instanceof go.GraphLinksModel) {
component.diagram.model.mergeLinkDataArray(this.linkDataArray);
}
component.diagram.model.commitTransaction('update data');
component.diagram.model.commit((m: go.Model) => {
// update modelData first, in case bindings on nodes / links depend on model data
component.diagram.model.assignAllDataProperties(this.diagram.model.modelData, this.modelData);
// merge node / link data
this.diagram.model.mergeNodeDataArray(this.nodeDataArray);
if (component.linkDataArray && component.diagram.model instanceof go.GraphLinksModel) {
component.diagram.model.mergeLinkDataArray(this.linkDataArray);
}
}, isInit ? null : 'merge data');

// reset the model change listener
if (component.modelChangedListener !== null) component.diagram.model.addChangedListener(this.modelChangedListener);
Expand Down

0 comments on commit cee59bd

Please sign in to comment.