diff --git a/src/static/js/broadcast.js b/src/static/js/broadcast.js index d4bda1110..9ac8ca3dc 100644 --- a/src/static/js/broadcast.js +++ b/src/static/js/broadcast.js @@ -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){ @@ -407,6 +395,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, @@ -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]);