diff --git a/src/node/db/Pad.js b/src/node/db/Pad.js index 0379f512a..664ad55ff 100644 --- a/src/node/db/Pad.js +++ b/src/node/db/Pad.js @@ -119,6 +119,7 @@ Pad.prototype.appendRevision = async function (aChangeset, author) { } await Promise.all(p); + return newRev; }; // save all attributes to the database diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 2c8c7ad77..cdc795a3d 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -639,8 +639,8 @@ const handleUserChanges = async (socket, message) => { `${Changeset.oldLen(rebasedChangeset)} to document of length ${prevText.length}`); } - await pad.appendRevision(rebasedChangeset, thisSession.author); - assert.equal(pad.getHeadRevisionNumber(), r + 1); + const newRev = await pad.appendRevision(rebasedChangeset, thisSession.author); + assert.equal(newRev, r + 1); const correctionChangeset = _correctMarkersInPad(pad.atext, pad.pool); if (correctionChangeset) { @@ -656,14 +656,9 @@ const handleUserChanges = async (socket, message) => { // 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); + socket.json.send({type: 'COLLABROOM', data: {type: 'ACCEPT_COMMIT', newRev}}); + thisSession.rev = newRev; + thisSession.time = await pad.getRevisionDate(newRev); await exports.updatePadClients(pad); } catch (err) { socket.json.send({disconnect: 'badChangeset'});