diff --git a/assets/js/src/newsletter_editor/components/history.js b/assets/js/src/newsletter_editor/components/history.js index e150830484..3c9f2f0b9f 100644 --- a/assets/js/src/newsletter_editor/components/history.js +++ b/assets/js/src/newsletter_editor/components/history.js @@ -62,12 +62,18 @@ Module.HistoryView = Marionette.View.extend({ if (!this.canUndo()) { return; } + this.model.currentStateIndex += 1; + this.updateArrowsUI(); + this.applyState(this.model.currentStateIndex); }, redo: function redo() { if (!this.canRedo()) { return; } + this.model.currentStateIndex -= 1; + this.updateArrowsUI(); + this.applyState(this.model.currentStateIndex); }, updateArrowsUI: function updateArrowsUI() { @@ -84,6 +90,11 @@ Module.HistoryView = Marionette.View.extend({ this.elements.redo.prop('title', MailPoet.I18n.t('canRedo')); } }, + + applyState: function applyState(index) { + const stateToApply = JSON.parse(this.model.states[index]); + App.getChannel().trigger('historyUpdate', stateToApply); + }, }); App.on('start', function appStart(StartApp) {