From 03c08b3875446ec7bc25ab8c0ccea83b600f2e74 Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Mon, 4 Apr 2022 00:20:46 -0700 Subject: [PATCH] fix history cancel button --- web/app/cad/craft/craftPlugin.ts | 26 +++++++++++++------------ web/app/cad/scene/views/openFaceView.js | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/web/app/cad/craft/craftPlugin.ts b/web/app/cad/craft/craftPlugin.ts index 48497b5b..34420da5 100644 --- a/web/app/cad/craft/craftPlugin.ts +++ b/web/app/cad/craft/craftPlugin.ts @@ -208,26 +208,28 @@ function isAdditiveChange({history:oldHistory, pointer:oldPointer}, {history, po } function historyTravel(modifications$) { - + + function setPointer(pointer, hints) { + let mod = modifications$.value; + if (pointer >= mod.history.length || pointer < -1) { + return; + } + modifications$.update(({history}) => ({history, pointer, hints})); + } + return { - setPointer: function(pointer, hints) { - let mod = modifications$.value; - if (pointer >= mod.history.length || pointer < -1) { - return; - } - modifications$.update(({history}) => ({history, pointer, hints})); - }, + setPointer, begin: function(hints) { - this.setPointer(-1, hints); + setPointer(-1, hints); }, end: function(hints) { - this.setPointer(modifications$.value.history.length - 1, hints); + setPointer(modifications$.value.history.length - 1, hints); }, forward: function(hints) { - this.setPointer(modifications$.value.pointer + 1, hints); + setPointer(modifications$.value.pointer + 1, hints); }, backward: function (hints) { - this.setPointer(modifications$.value.pointer - 1, hints); + setPointer(modifications$.value.pointer - 1, hints); }, } diff --git a/web/app/cad/scene/views/openFaceView.js b/web/app/cad/scene/views/openFaceView.js index ceeb1e5e..6cd30a1b 100644 --- a/web/app/cad/scene/views/openFaceView.js +++ b/web/app/cad/scene/views/openFaceView.js @@ -14,7 +14,7 @@ export class OpenFaceShellView extends View { } get rootGroup() { - return this.openFace.rootGroup + return this.openFace?.rootGroup } dispose() {