mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
PadMessageHandler: Move ACCEPT_COMMIT
after changeset save
This commit is contained in:
parent
dbacc73c36
commit
c05ee7ce72
1 changed files with 25 additions and 18 deletions
|
@ -640,6 +640,7 @@ const handleUserChanges = async (socket, message) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
await pad.appendRevision(rebasedChangeset, thisSession.author);
|
await pad.appendRevision(rebasedChangeset, thisSession.author);
|
||||||
|
assert.equal(pad.getHeadRevisionNumber(), r + 1);
|
||||||
|
|
||||||
const correctionChangeset = _correctMarkersInPad(pad.atext, pad.pool);
|
const correctionChangeset = _correctMarkersInPad(pad.atext, pad.pool);
|
||||||
if (correctionChangeset) {
|
if (correctionChangeset) {
|
||||||
|
@ -652,6 +653,17 @@ const handleUserChanges = async (socket, message) => {
|
||||||
await pad.appendRevision(nlChangeset);
|
await pad.appendRevision(nlChangeset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The client assumes that ACCEPT_COMMIT and NEW_CHANGES messages arrive in order. Make sure we
|
||||||
|
// have already sent any previous ACCEPT_COMMIT and NEW_CHANGES messages.
|
||||||
|
assert.equal(thisSession.rev, r);
|
||||||
|
socket.json.send({
|
||||||
|
type: 'COLLABROOM',
|
||||||
|
data: {
|
||||||
|
type: 'ACCEPT_COMMIT',
|
||||||
|
newRev: ++thisSession.rev,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
thisSession.time = await pad.getRevisionDate(thisSession.rev);
|
||||||
await exports.updatePadClients(pad);
|
await exports.updatePadClients(pad);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
socket.json.send({disconnect: 'badChangeset'});
|
socket.json.send({disconnect: 'badChangeset'});
|
||||||
|
@ -697,12 +709,8 @@ exports.updatePadClients = async (pad) => {
|
||||||
const revChangeset = revision.changeset;
|
const revChangeset = revision.changeset;
|
||||||
const currentTime = revision.meta.timestamp;
|
const currentTime = revision.meta.timestamp;
|
||||||
|
|
||||||
let msg;
|
|
||||||
if (author === sessioninfo.author) {
|
|
||||||
msg = {type: 'COLLABROOM', data: {type: 'ACCEPT_COMMIT', newRev: r}};
|
|
||||||
} else {
|
|
||||||
const forWire = Changeset.prepareForWire(revChangeset, pad.pool);
|
const forWire = Changeset.prepareForWire(revChangeset, pad.pool);
|
||||||
msg = {
|
const msg = {
|
||||||
type: 'COLLABROOM',
|
type: 'COLLABROOM',
|
||||||
data: {
|
data: {
|
||||||
type: 'NEW_CHANGES',
|
type: 'NEW_CHANGES',
|
||||||
|
@ -714,7 +722,6 @@ exports.updatePadClients = async (pad) => {
|
||||||
timeDelta: currentTime - sessioninfo.time,
|
timeDelta: currentTime - sessioninfo.time,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
socket.json.send(msg);
|
socket.json.send(msg);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in a new issue