Fixed undo/redo

This commit is contained in:
orangemug 2020-02-01 17:53:01 +00:00
parent f09cc25a3b
commit 3e2927e6a4

View file

@ -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: [],
})
}