This reverts commit 741ed00bda
.
This was causing a bug with computed's not getting invalidated
correctly. To reproduce:
- Draw a rectangle
- Hold alt to drag out a duplicate
- Delete the duplicate
We'd then get errors and sometimes a crash where the indicator continued
trying to render a now-deleted shape.
### Change Type
- [x] `sdk` — Changes the tldraw SDK
- [x] `bugfix` — Bug fix
This commit is contained in:
parent
8151e6f586
commit
4c5abe888c
2 changed files with 3 additions and 14 deletions
|
@ -4,7 +4,7 @@ import { HistoryBuffer } from './HistoryBuffer'
|
||||||
import { maybeCaptureParent, startCapturingParents, stopCapturingParents } from './capture'
|
import { maybeCaptureParent, startCapturingParents, stopCapturingParents } from './capture'
|
||||||
import { GLOBAL_START_EPOCH } from './constants'
|
import { GLOBAL_START_EPOCH } from './constants'
|
||||||
import { EMPTY_ARRAY, equals, haveParentsChanged, singleton } from './helpers'
|
import { EMPTY_ARRAY, equals, haveParentsChanged, singleton } from './helpers'
|
||||||
import { getGlobalEpoch, getIsReacting } from './transactions'
|
import { getGlobalEpoch } from './transactions'
|
||||||
import { Child, ComputeDiff, RESET_VALUE, Signal } from './types'
|
import { Child, ComputeDiff, RESET_VALUE, Signal } from './types'
|
||||||
import { logComputedGetterWarning } from './warnings'
|
import { logComputedGetterWarning } from './warnings'
|
||||||
|
|
||||||
|
@ -189,15 +189,8 @@ class __UNSAFE__Computed<Value, Diff = unknown> implements Computed<Value, Diff>
|
||||||
__unsafe__getWithoutCapture(ignoreErrors?: boolean): Value {
|
__unsafe__getWithoutCapture(ignoreErrors?: boolean): Value {
|
||||||
const isNew = this.lastChangedEpoch === GLOBAL_START_EPOCH
|
const isNew = this.lastChangedEpoch === GLOBAL_START_EPOCH
|
||||||
|
|
||||||
const globalEpoch = getGlobalEpoch()
|
if (!isNew && (this.lastCheckedEpoch === getGlobalEpoch() || !haveParentsChanged(this))) {
|
||||||
|
this.lastCheckedEpoch = getGlobalEpoch()
|
||||||
if (
|
|
||||||
!isNew &&
|
|
||||||
(this.lastCheckedEpoch === globalEpoch ||
|
|
||||||
(this.isActivelyListening && getIsReacting() && this.lastTraversedEpoch < globalEpoch) ||
|
|
||||||
!haveParentsChanged(this))
|
|
||||||
) {
|
|
||||||
this.lastCheckedEpoch = globalEpoch
|
|
||||||
if (this.error) {
|
if (this.error) {
|
||||||
if (!ignoreErrors) {
|
if (!ignoreErrors) {
|
||||||
throw this.error.thrownValue
|
throw this.error.thrownValue
|
||||||
|
|
|
@ -70,10 +70,6 @@ export function getGlobalEpoch() {
|
||||||
return inst.globalEpoch
|
return inst.globalEpoch
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getIsReacting() {
|
|
||||||
return inst.globalIsReacting
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collect all of the reactors that need to run for an atom and run them.
|
* Collect all of the reactors that need to run for an atom and run them.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue