Fix timeslider revision not changing in most cases

pull/2220/head
Stefan 2014-08-09 18:52:44 +02:00
parent e34a4ea4ee
commit bb21759d78
1 changed files with 23 additions and 17 deletions

View File

@ -384,22 +384,10 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
}
if (changeset) applyChangeset(changeset, path.rev, true, timeDelta);
if (BroadcastSlider.getSliderLength() > 10000)
{
var start = (Math.floor((newRevision) / 10000) * 10000); // revision 0 to 10
changesetLoader.queueUp(start, 100);
}
if (BroadcastSlider.getSliderLength() > 1000)
{
var start = (Math.floor((newRevision) / 1000) * 1000); // (start from -1, go to 19) + 1
changesetLoader.queueUp(start, 10);
}
start = (Math.floor((newRevision) / 100) * 100);
changesetLoader.queueUp(start, 1, update);
// Loading changeset history for new revision
loadChangesetsForRevision(newRevision, update);
// Loading changeset history for old revision (to make diff between old and new revision)
loadChangesetsForRevision(padContents.currentRevision - 1);
}
var authors = _.map(padContents.getActiveAuthors(), function(name){
@ -408,6 +396,24 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
BroadcastSlider.setAuthors(authors);
}
function loadChangesetsForRevision(revision, callback) {
if (BroadcastSlider.getSliderLength() > 10000)
{
var start = (Math.floor((revision) / 10000) * 10000); // revision 0 to 10
changesetLoader.queueUp(start, 100);
}
if (BroadcastSlider.getSliderLength() > 1000)
{
var start = (Math.floor((revision) / 1000) * 1000); // (start from -1, go to 19) + 1
changesetLoader.queueUp(start, 10);
}
start = (Math.floor((revision) / 100) * 100);
changesetLoader.queueUp(start, 1, callback);
}
changesetLoader = {
running: false,
resolved: [],
@ -482,7 +488,7 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
var astart = start + i * granularity - 1; // rev -1 is a blank single line
var aend = start + (i + 1) * granularity - 1; // totalRevs is the most recent revision
if (aend > data.actualEndNum - 1) aend = data.actualEndNum - 1;
debugLog("adding changeset:", astart, aend);
//debugLog("adding changeset:", astart, aend);
var forwardcs = Changeset.moveOpsToNewPool(data.forwardsChangesets[i], pool, padContents.apool);
var backwardcs = Changeset.moveOpsToNewPool(data.backwardsChangesets[i], pool, padContents.apool);
revisionInfo.addChangeset(astart, aend, forwardcs, backwardcs, data.timeDeltas[i]);