fix: some persist issues

pull/5775/head
Peng Xiao 2022-05-21 19:17:09 +08:00
parent e46fb4ee62
commit e86b0eb2a6
4 changed files with 8 additions and 1 deletions

View File

@ -11,6 +11,10 @@ export class TLHistory<S extends TLShape = TLShape, K extends TLEventMap = TLEve
pointer = 0 pointer = 0
isPaused = true isPaused = true
get creating() {
return this.app.selectedTool.currentState.id === 'creating';
}
pause = () => { pause = () => {
if (this.isPaused) return if (this.isPaused) return
this.isPaused = true this.isPaused = true
@ -30,7 +34,7 @@ export class TLHistory<S extends TLShape = TLShape, K extends TLEventMap = TLEve
} }
persist = () => { persist = () => {
if (this.isPaused) return if (this.isPaused || this.creating) return
const { serialized } = this.app const { serialized } = this.app

View File

@ -46,6 +46,7 @@ export class CreatingState<
if (!this.app.settings.isToolLocked) { if (!this.app.settings.isToolLocked) {
this.app.transition('select') this.app.transition('select')
} }
this.app.persist()
} }
onWheel: TLStateEvents<S, K>['onWheel'] = (info, e) => { onWheel: TLStateEvents<S, K>['onWheel'] = (info, e) => {

View File

@ -88,6 +88,7 @@ export class CreatingState<
}) })
this.tool.previousShape = this.shape this.tool.previousShape = this.shape
this.tool.transition('idle') this.tool.transition('idle')
this.app.persist()
} }
onWheel: TLStateEvents<S, K>['onWheel'] = (info, e) => { onWheel: TLStateEvents<S, K>['onWheel'] = (info, e) => {

View File

@ -57,6 +57,7 @@ export class CreatingState<
if (!this.app.settings.isToolLocked) { if (!this.app.settings.isToolLocked) {
this.app.transition('select') this.app.transition('select')
} }
this.app.persist()
} }
onWheel: TLStateEvents<S, K>['onWheel'] = (info, e) => { onWheel: TLStateEvents<S, K>['onWheel'] = (info, e) => {