mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
Allow compose or apply to be used in GoToRevision
Controlled on the static PadClient.USE_COMPOSE variable.
This commit is contained in:
parent
13f4a71aba
commit
a5eced9952
2 changed files with 16 additions and 13 deletions
|
@ -141,7 +141,6 @@ $.Class("RevisionSlider",
|
||||||
revnum = this.connection.latest_revision;
|
revnum = this.connection.latest_revision;
|
||||||
if (revnum < 0)
|
if (revnum < 0)
|
||||||
revnum = 0;
|
revnum = 0;
|
||||||
console.log("GO TO REVISION", revnum);
|
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
this.connection.goToRevision(revnum, function (revision, timestamp) {
|
this.connection.goToRevision(revnum, function (revision, timestamp) {
|
||||||
|
|
|
@ -33,7 +33,6 @@ $.Class("Changeset",
|
||||||
var newvalue = libchangeset.compose(this.value, other.value, pad.apool);
|
var newvalue = libchangeset.compose(this.value, other.value, pad.apool);
|
||||||
var newchangeset = new Changeset(this.from_revision, other.to_revision,
|
var newchangeset = new Changeset(this.from_revision, other.to_revision,
|
||||||
this.deltatime + other.deltatime, newvalue);
|
this.deltatime + other.deltatime, newvalue);
|
||||||
console.log(newchangeset);
|
|
||||||
//TODO: insert new changeset into the graph somehow.
|
//TODO: insert new changeset into the graph somehow.
|
||||||
return newchangeset;
|
return newchangeset;
|
||||||
},
|
},
|
||||||
|
@ -526,6 +525,7 @@ var domline = require("./domline").domline;
|
||||||
var linestylefilter = require("./linestylefilter").linestylefilter;
|
var linestylefilter = require("./linestylefilter").linestylefilter;
|
||||||
$.Class("PadClient",
|
$.Class("PadClient",
|
||||||
{//static
|
{//static
|
||||||
|
USE_COMPOSE: true,
|
||||||
},
|
},
|
||||||
{//instance
|
{//instance
|
||||||
/**
|
/**
|
||||||
|
@ -580,22 +580,26 @@ $.Class("PadClient",
|
||||||
this.revisionCache.transition(this.revision.revnum, revnum, function (path) {
|
this.revisionCache.transition(this.revision.revnum, revnum, function (path) {
|
||||||
console.log("[padclient > applyChangeset_callback] path:", path);
|
console.log("[padclient > applyChangeset_callback] path:", path);
|
||||||
var time = _this.timestamp;
|
var time = _this.timestamp;
|
||||||
|
if (PadClient.USE_COMPOSE) {
|
||||||
var composed = path[0];
|
var composed = path[0];
|
||||||
var _path = path.slice(1);
|
var _path = path.slice(1);
|
||||||
for (var p in _path) {
|
for (var p in _path) {
|
||||||
console.log(p, _path[p].deltatime, _path[p].value);
|
|
||||||
var changeset = _path[p];
|
var changeset = _path[p];
|
||||||
composed = composed.compose(changeset, _this);
|
composed = composed.compose(changeset, _this);
|
||||||
//time += changeset.deltatime * 1000;
|
|
||||||
//changeset.apply(_this);
|
|
||||||
}
|
}
|
||||||
composed.apply(_this);
|
composed.apply(_this);
|
||||||
time += composed.deltatime * 1000;
|
time += composed.deltatime * 1000;
|
||||||
|
} else { // Don't compose, just apply
|
||||||
|
for (var p in path) {
|
||||||
|
var changeset = path[p];
|
||||||
|
time += changeset.deltatime * 1000;
|
||||||
|
changeset.apply(_this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// set revision and timestamp
|
// set revision and timestamp
|
||||||
_this.revision = path.slice(-1)[0].to_revision;
|
_this.revision = path.slice(-1)[0].to_revision;
|
||||||
_this.timestamp = time;
|
_this.timestamp = time;
|
||||||
console.log(_this.revision, _this.timestamp);
|
|
||||||
// fire the callback
|
// fire the callback
|
||||||
if (atRevision_callback) {
|
if (atRevision_callback) {
|
||||||
console.log("[padclient] about to call atRevision_callback", _this.revision, _this.timestamp);
|
console.log("[padclient] about to call atRevision_callback", _this.revision, _this.timestamp);
|
||||||
|
|
Loading…
Reference in a new issue