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
  • Loading branch information
AndreiMazol authored Nov 16, 2021
1 parent 805b6c9 commit f752f14
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
20 changes: 16 additions & 4 deletions packages/ketcher-core/src/domain/entities/SGroupForest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/

import { Pile } from './Pile'
import { SGroup } from './SGroup'

Expand All @@ -34,13 +35,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
queue = queue.concat(this.children.get(id) as any)
const id = queue.shift()
if (typeof id !== 'number') {
break
}
const children = this.children.get(id)
if (typeof children === 'undefined') {
break
}

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

order.push(id)
}

return order
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,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 @@ -55,7 +55,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

0 comments on commit f752f14

Please sign in to comment.