From 3e2927e6a481f4c29453c98be85d11e85f8edc53 Mon Sep 17 00:00:00 2001 From: orangemug Date: Sat, 1 Feb 2020 17:53:01 +0000 Subject: [PATCH] Fixed undo/redo --- src/components/App.jsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/App.jsx b/src/components/App.jsx index d8d6d16..79424e7 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -370,12 +370,23 @@ export default class App extends React.Component { } onUndo = () => { - const activeStyle = this.revisionStore.undo() + let activeStyle; + + // Check our dirty style state first, otherwise just undo to that state. + if (isEqual(this.state.mapStyle, this.state.hopefulMapStyle)) { + activeStyle = this.revisionStore.undo() + } + else { + activeStyle = this.state.mapStyle; + } + const messages = undoMessages(this.state.hopefulMapStyle, activeStyle) this.saveStyle(activeStyle) this.setState({ - mapStyle: activeStyle, infos: messages, + mapStyle: activeStyle, + hopefulMapStyle: activeStyle, + errors: [], }) } @@ -384,8 +395,10 @@ export default class App extends React.Component { const messages = redoMessages(this.state.hopefulMapStyle, activeStyle) this.saveStyle(activeStyle) this.setState({ - mapStyle: activeStyle, infos: messages, + mapStyle: activeStyle, + hopefulMapStyle: activeStyle, + errors: [], }) }