Filter relevant updates

This commit is contained in:
Chen-I Lim 2020-11-06 14:07:04 -08:00
parent 0cca55126c
commit c00902cb6b
3 changed files with 14 additions and 2 deletions

View file

@ -59,7 +59,11 @@ class MutableBoardTree implements BoardTree {
}
incrementalUpdate(updatedBlocks: IBlock[]) {
this.rawBlocks = OctoUtils.mergeBlocks(this.rawBlocks, updatedBlocks)
const relevantBlocks = updatedBlocks.filter((block) => block.id === this.boardId || block.parentId === this.boardId)
if (relevantBlocks.length < 1) {
return
}
this.rawBlocks = OctoUtils.mergeBlocks(this.rawBlocks, relevantBlocks)
this.rebuild(OctoUtils.hydrateBlocks(this.rawBlocks))
}

View file

@ -30,7 +30,11 @@ class MutableCardTree implements CardTree {
}
incrementalUpdate(updatedBlocks: IBlock[]) {
this.rawBlocks = OctoUtils.mergeBlocks(this.rawBlocks, updatedBlocks)
const relevantBlocks = updatedBlocks.filter((block) => block.id === this.cardId || block.parentId === this.cardId)
if (relevantBlocks.length < 1) {
return
}
this.rawBlocks = OctoUtils.mergeBlocks(this.rawBlocks, relevantBlocks)
this.rebuild(OctoUtils.hydrateBlocks(this.rawBlocks))
}

View file

@ -27,6 +27,10 @@ class MutableWorkspaceTree {
}
incrementalUpdate(updatedBlocks: IBlock[]) {
const relevantBlocks = updatedBlocks.filter((block) => block.type === 'board' || block.type === 'view')
if (relevantBlocks.length < 1) {
return
}
this.rawBlocks = OctoUtils.mergeBlocks(this.rawBlocks, updatedBlocks)
this.rebuild(OctoUtils.hydrateBlocks(this.rawBlocks))
}