mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
restored history snapshot interval to 50
This commit is contained in:
parent
5350255eee
commit
56f008bda6
@ -1,7 +1,7 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var ns = $.namespace('pskl.service');
|
var ns = $.namespace('pskl.service');
|
||||||
|
|
||||||
var SNAPSHOT_PERIOD = 5;
|
var SNAPSHOT_PERIOD = 50;
|
||||||
var LOAD_STATE_INTERVAL = 50;
|
var LOAD_STATE_INTERVAL = 50;
|
||||||
|
|
||||||
ns.HistoryService = function (piskelController) {
|
ns.HistoryService = function (piskelController) {
|
||||||
@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
var isSnapshot = stateInfo.type === ns.HistoryService.SNAPSHOT;
|
var isSnapshot = stateInfo.type === ns.HistoryService.SNAPSHOT;
|
||||||
var isNoSnapshot = stateInfo.type === ns.HistoryService.REPLAY_NO_SNAPSHOT;
|
var isNoSnapshot = stateInfo.type === ns.HistoryService.REPLAY_NO_SNAPSHOT;
|
||||||
var isAtAutoSnapshotInterval = this.currentIndex % SNAPSHOT_PERIOD === 0;
|
var isAtAutoSnapshotInterval = this.currentIndex % SNAPSHOT_PERIOD === 0 || this.saveNextAsSnapshot;
|
||||||
if (isNoSnapshot && isAtAutoSnapshotInterval) {
|
if (isNoSnapshot && isAtAutoSnapshotInterval) {
|
||||||
this.saveNextAsSnapshot = true;
|
this.saveNextAsSnapshot = true;
|
||||||
} else if (isSnapshot || isAtAutoSnapshotInterval) {
|
} else if (isSnapshot || isAtAutoSnapshotInterval) {
|
||||||
@ -58,6 +58,10 @@
|
|||||||
this.saveNextAsSnapshot = false;
|
this.saveNextAsSnapshot = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isSnapshot) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
this.stateQueue.push(state);
|
this.stateQueue.push(state);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,12 +80,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ns.HistoryService.prototype.getPreviousSnapshotIndex_ = function (index) {
|
ns.HistoryService.prototype.getPreviousSnapshotIndex_ = function (index) {
|
||||||
var counter = 0;
|
|
||||||
while (this.stateQueue[index] && !this.stateQueue[index].piskel) {
|
while (this.stateQueue[index] && !this.stateQueue[index].piskel) {
|
||||||
index = index - 1;
|
index = index - 1;
|
||||||
if(++counter > 2*SNAPSHOT_PERIOD) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return index;
|
return index;
|
||||||
};
|
};
|
||||||
@ -101,8 +101,6 @@
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
window.console.error("[CRITICAL ERROR] : Unable to load a history state.");
|
window.console.error("[CRITICAL ERROR] : Unable to load a history state.");
|
||||||
window.console.error("Can you open an issue on http://github.com/juliandescottes/piskel or contact @piskelapp on twitter ? Thanks !");
|
|
||||||
window.console.error("Thanks !");
|
|
||||||
if (typeof e === "string") {
|
if (typeof e === "string") {
|
||||||
window.console.error(e);
|
window.console.error(e);
|
||||||
} else {
|
} else {
|
||||||
@ -140,7 +138,7 @@
|
|||||||
this.replayState(state);
|
this.replayState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastState = this.stateQueue[index];
|
var lastState = this.stateQueue[index+1];
|
||||||
if (lastState) {
|
if (lastState) {
|
||||||
this.setupState(lastState);
|
this.setupState(lastState);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user