Refactor templateCopy
This commit is contained in:
parent
02d26a800a
commit
3961a8a314
2 changed files with 4 additions and 10 deletions
|
@ -408,7 +408,7 @@ class MutableBoardTree implements BoardTree {
|
|||
}
|
||||
|
||||
templateCopy(): MutableBoardTree {
|
||||
const [newBlocks, newBoard] = OctoUtils.duplicateBlockTree(this.allBlocks, this.board.id)
|
||||
const [newBlocks, newBoard] = OctoUtils.duplicateBlockTree(this.rawBlocks, this.board.id)
|
||||
|
||||
const boardTree = new MutableBoardTree(newBoard.id)
|
||||
boardTree.incrementalUpdate(newBlocks)
|
||||
|
|
|
@ -58,16 +58,10 @@ class MutableCardTree implements CardTree {
|
|||
}
|
||||
|
||||
templateCopy(): MutableCardTree {
|
||||
const card = this.card.duplicate()
|
||||
const [newBlocks, newCard] = OctoUtils.duplicateBlockTree(this.rawBlocks, this.card.id)
|
||||
|
||||
const contents: IOrderedBlock[] = this.contents.map((content) => {
|
||||
const copy = MutableBlock.duplicate(content)
|
||||
copy.parentId = card.id
|
||||
return copy as IOrderedBlock
|
||||
})
|
||||
|
||||
const cardTree = new MutableCardTree(card.id)
|
||||
cardTree.incrementalUpdate([card, ...contents])
|
||||
const cardTree = new MutableCardTree(newCard.id)
|
||||
cardTree.incrementalUpdate(newBlocks)
|
||||
return cardTree
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue