[perf] deleteShapes (#1373)
This PR extracts a static query for the page states that are used when deleting a shape. ### Change Type <!-- 💡 Indicate the type of change your pull request is. --> <!-- 🤷♀️ If you're not sure, don't select anything --> <!-- ✂️ Feel free to delete unselected options --> <!-- To select one, put an x in the box: [x] --> - [x] `patch` — Bug Fix ### Release Notes - Perf improvement for deleting shapes in a document with lots of pages.
This commit is contained in:
parent
bd455b0b8b
commit
fff9c4c09b
1 changed files with 5 additions and 1 deletions
|
@ -1296,6 +1296,10 @@ export class App extends EventEmitter<TLEventMap> {
|
||||||
// const update = this.getShapeUtil(next).onUpdate?.(prev, next)
|
// const update = this.getShapeUtil(next).onUpdate?.(prev, next)
|
||||||
// return update ?? next
|
// return update ?? next
|
||||||
// }
|
// }
|
||||||
|
@computed
|
||||||
|
private get _allPageStates() {
|
||||||
|
return this.store.query.records('instance_page_state')
|
||||||
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
private _shapeWillBeDeleted(deletedShape: TLShape) {
|
private _shapeWillBeDeleted(deletedShape: TLShape) {
|
||||||
|
@ -1312,8 +1316,8 @@ export class App extends EventEmitter<TLEventMap> {
|
||||||
this._unbindArrowTerminal(arrow, handleId)
|
this._unbindArrowTerminal(arrow, handleId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const pageStates = this._allPageStates.value
|
||||||
|
|
||||||
const pageStates = this.store.query.records('instance_page_state').value
|
|
||||||
const deletedIds = new Set([deletedShape.id])
|
const deletedIds = new Set([deletedShape.id])
|
||||||
const updates = compact(
|
const updates = compact(
|
||||||
pageStates.map((pageState) => {
|
pageStates.map((pageState) => {
|
||||||
|
|
Loading…
Reference in a new issue