Send commits missed during the reconnect

This commit is contained in:
anugu-chegg 2018-02-14 13:18:44 +05:30 committed by muxator
parent bf05e9ae89
commit d41e184a3c
2 changed files with 36 additions and 9 deletions

View file

@ -342,6 +342,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
}
else if (msg.type == 'CLIENT_RECONNECT')
{
// When client has reconnected but there are no pending changes from other clients
if (msg.noChanges)
{
socketIOError = false;
@ -354,19 +355,26 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
var author = (msg.author || '');
var apool = msg.apool;
if (rev + 1 == currRev)
{
if (author == pad.getUserId())
{
editor.applyPreparedChangesetToBase();
setStateIdle();
callCatchingErrors("onInternalAction", function()
{
callbacks.onInternalAction("commitAcceptedByServer");
});
callCatchingErrors("onConnectionTrouble", function()
{
callbacks.onConnectionTrouble("OK");
});
handleUserChanges();
}
else
{
editor.applyChangesToBase(changeset, author, apool);
}
}
if (rev + 1 < currRev)
{
@ -374,8 +382,8 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
}
if (currRev == newRev)
{
socketIOError = false;
rev = newRev;
socketIOError = false;
}
}
else if (msg.type == "NO_COMMIT_PENDING")