Sanitize currentStateIndex
[MAILPOET-1976]
This commit is contained in:
@@ -67,14 +67,14 @@ Module.HistoryView = Marionette.View.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
canRedo: function canRedo() {
|
canRedo: function canRedo() {
|
||||||
return this.model.currentStateIndex !== 0;
|
return this.model.currentStateIndex > 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
undo: function undo() {
|
undo: function undo() {
|
||||||
if (!this.canUndo()) {
|
if (!this.canUndo()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.model.currentStateIndex += 1;
|
this.model.currentStateIndex = Math.min(this.model.statesStack.length - 1, this.model.currentStateIndex + 1);
|
||||||
this.updateArrowsUI();
|
this.updateArrowsUI();
|
||||||
this.applyState(this.model.currentStateIndex);
|
this.applyState(this.model.currentStateIndex);
|
||||||
},
|
},
|
||||||
@@ -83,7 +83,7 @@ Module.HistoryView = Marionette.View.extend({
|
|||||||
if (!this.canRedo()) {
|
if (!this.canRedo()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.model.currentStateIndex -= 1;
|
this.model.currentStateIndex = Math.max(0, this.model.currentStateIndex - 1);
|
||||||
this.updateArrowsUI();
|
this.updateArrowsUI();
|
||||||
this.applyState(this.model.currentStateIndex);
|
this.applyState(this.model.currentStateIndex);
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user