Set initial state

[MAILPOET-1976]
This commit is contained in:
Ján Mikláš
2019-05-29 16:30:55 +02:00
committed by M. Shull
parent 5e17532911
commit 16ba2490c9

View File

@@ -34,7 +34,7 @@ Module.HistoryView = Marionette.View.extend({
onAttach: function onRender() { onAttach: function onRender() {
this.elements.redo = jQuery('#mailpoet-history-arrow-redo'); this.elements.redo = jQuery('#mailpoet-history-arrow-redo');
this.elements.undo = jQuery('#mailpoet-history-arrow-undo'); this.elements.undo = jQuery('#mailpoet-history-arrow-undo');
this.updateArrowsUI(); this.setCurrentState(App.toJSON());
}, },
setCurrentState: function setCurrentState(json) { setCurrentState: function setCurrentState(json) {
@@ -44,7 +44,7 @@ Module.HistoryView = Marionette.View.extend({
if (this.model.currentStateIndex > 0) { if (this.model.currentStateIndex > 0) {
this.model.states.splice(0, this.model.currentStateIndex); this.model.states.splice(0, this.model.currentStateIndex);
} }
this.model.states.unshift(json.body); this.model.states.unshift(JSON.stringify(json.body));
this.model.currentStateIndex = 0; this.model.currentStateIndex = 0;
this.model.states.length = Math.min(this.model.states.length, this.MAX_HISTORY_STATES); this.model.states.length = Math.min(this.model.states.length, this.MAX_HISTORY_STATES);
this.updateArrowsUI(); this.updateArrowsUI();