Skip to content

Commit

Permalink
#975 Application hangs after undo action applying to S-Group type cha…
Browse files Browse the repository at this point in the history
…nges (#978)

update priority of s-group hierarchy operations
# Conflicts:
#	packages/ketcher-core/src/domain/entities/sgroupForest.ts
  • Loading branch information
AndreiMazol committed Nov 16, 2021
1 parent e3348e1 commit 41597e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SGroupAddToHierarchy extends BaseOperation {
data: Data

constructor(sgroupId?: any, parent?: any, children?: any) {
super(OperationType.S_GROUP_ADD_TO_HIERACHY, 4)
super(OperationType.S_GROUP_ADD_TO_HIERACHY, 100)
this.data = { sgid: sgroupId, parent, children }
}

Expand All @@ -56,7 +56,7 @@ class SGroupRemoveFromHierarchy extends BaseOperation {
data: Data

constructor(sgroupId?: any) {
super(OperationType.S_GROUP_REMOVE_FROM_HIERACHY)
super(OperationType.S_GROUP_REMOVE_FROM_HIERACHY, 110)
this.data = { sgid: sgroupId }
}

Expand Down
18 changes: 14 additions & 4 deletions packages/ketcher-core/src/domain/entities/sgroupForest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,24 @@ export class SGroupForest {
/** returns an array or s-group ids in the order of breadth-first search */
getSGroupsBFS(): number[] {
const order: number[] = []
let id = -1
let queue = Array.from(this.children.get(-1) as any)
const queue = Array.from(this.children.get(-1) as Array<number>)
while (queue.length > 0) {
id = queue.shift() as any
const id = queue.shift()
if (typeof id !== 'number') {
break
}
const children = this.children.get(id)
queue = queue.concat(children as any)
if (typeof children === 'undefined') {
break
}

children.forEach(id => {
queue.push(id)
})

order.push(id)
}

return order
}

Expand Down

0 comments on commit 41597e6

Please sign in to comment.