Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions frontend/webEditor/src/serialize/loadJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,7 @@ export abstract class LoadJsonCommand extends Command {
this.constraintRegistry.clearConstraints();
}

const containsUnPositionedNodes = this.newRoot.children
.filter((child) => child instanceof SNodeImpl)
.some((child) => isLocateable(child) && child.position.x === 0 && child.position.y === 0);
if (containsUnPositionedNodes) {
await this.actionDispatcher.dispatch(LayoutModelAction.create(LayoutMethod.LINES));
}
await this.actionDispatcher.dispatch(DefaultFitToScreenAction.create(this.newRoot));
this.postLoadActions();

this.oldFileName = this.fileName.getName();
this.fileName.setName(this.file.fileName);
Expand Down Expand Up @@ -213,4 +207,18 @@ export abstract class LoadJsonCommand extends Command {
}
return modelSchema;
}

private async postLoadActions() {
if (!this.newRoot) {
return;
}

const containsUnPositionedNodes = this.newRoot.children
.filter((child) => child instanceof SNodeImpl)
.some((child) => isLocateable(child) && child.position.x === 0 && child.position.y === 0);
if (containsUnPositionedNodes) {
await this.actionDispatcher.dispatch(LayoutModelAction.create(LayoutMethod.LINES));
}
return this.actionDispatcher.dispatch(DefaultFitToScreenAction.create(this.newRoot, false));
}
}