Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix issue #336

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions app/pages/SketchModeling/SketchList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const SketchList: React.FC = () => {
}
const isModified = checkModified();
if(!isModified) {
sketchModel.destroy();
update({ currentSketch: list.items[0], active: null });
return;
}
Expand Down
6 changes: 3 additions & 3 deletions app/stores/sketchModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class SketchStore {
};

validateSchema = async () => {
const data = await this.editor.schema.getData();
const data = await this.editor?.schema?.getData();
const { nodes, lines } = data;
const nodesValid = nodes.reduce((flag, node) => this.validate(node, 'node') && flag, true);
const edgesValid = lines.reduce((flag, line) => this.validate(line, 'edge') && flag, true);
Expand All @@ -109,7 +109,7 @@ export class SketchStore {
};

checkSameName = () => {
const data = this.editor.schema.getData();
const data = this.editor?.schema?.getData();
const { nodes, lines } = data;
const _nodes = nodes.map((i) => i.name).filter(Boolean);
const _lines = lines.map((i) => i.name).filter(Boolean);
Expand All @@ -119,7 +119,7 @@ export class SketchStore {

checkModified = () => {
const initialData = this.sketchList.items.find((item) => item.id === this.currentSketch?.id);
const schema = this.editor.schema.getData();
const schema = this.editor?.schema?.getData();
const isEmptySame = !schema.nodes.length && !schema.lines.length && !initialData.schema;
const newSchema = JSON.stringify({
nodes: schema.nodes?.map(node => ({ name: node.name, properties: node.properties, comment: node.comment })),
Expand Down