mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
For duplicate ops only send ack to submitting client
When a duplicate op is received, we only need to ack it to client that sent it. Only that client is having trouble, and all other clients will already have received it.
This commit is contained in:
parent
669cb0c085
commit
503b766dcc
2 changed files with 35 additions and 16 deletions
|
@ -24,7 +24,7 @@ module.exports = DocumentUpdaterController =
|
|||
if client.id == update.meta.source
|
||||
logger.log doc_id: doc_id, version: update.v, source: update.meta?.source, "distributing update to sender"
|
||||
client.emit "otUpdateApplied", v: update.v, doc: update.doc
|
||||
else
|
||||
else if !update.dup # Duplicate ops should just be sent back to sending client for acknowledgement
|
||||
logger.log doc_id: doc_id, version: update.v, source: update.meta?.source, client_id: client.id, "distributing update to collaborator"
|
||||
client.emit "otUpdateApplied", update
|
||||
|
||||
|
|
|
@ -68,24 +68,43 @@ describe "DocumentUpdaterController", ->
|
|||
doc: @doc_id
|
||||
@io.sockets =
|
||||
clients: sinon.stub().returns([@sourceClient, @otherClients...])
|
||||
@EditorUpdatesController._applyUpdateFromDocumentUpdater @io, @doc_id, @update
|
||||
|
||||
describe "normally", ->
|
||||
beforeEach ->
|
||||
@EditorUpdatesController._applyUpdateFromDocumentUpdater @io, @doc_id, @update
|
||||
|
||||
it "should send a version bump to the source client", ->
|
||||
@sourceClient.emit
|
||||
.calledWith("otUpdateApplied", v: @version, doc: @doc_id)
|
||||
.should.equal true
|
||||
|
||||
it "should get the clients connected to the document", ->
|
||||
@io.sockets.clients
|
||||
.calledWith(@doc_id)
|
||||
.should.equal true
|
||||
|
||||
it "should send the full update to the other clients", ->
|
||||
for client in @otherClients
|
||||
client.emit
|
||||
.calledWith("otUpdateApplied", @update)
|
||||
it "should send a version bump to the source client", ->
|
||||
@sourceClient.emit
|
||||
.calledWith("otUpdateApplied", v: @version, doc: @doc_id)
|
||||
.should.equal true
|
||||
|
||||
it "should get the clients connected to the document", ->
|
||||
@io.sockets.clients
|
||||
.calledWith(@doc_id)
|
||||
.should.equal true
|
||||
|
||||
it "should send the full update to the other clients", ->
|
||||
for client in @otherClients
|
||||
client.emit
|
||||
.calledWith("otUpdateApplied", @update)
|
||||
.should.equal true
|
||||
|
||||
describe "with a duplicate op", ->
|
||||
beforeEach ->
|
||||
@update.dup = true
|
||||
@EditorUpdatesController._applyUpdateFromDocumentUpdater @io, @doc_id, @update
|
||||
|
||||
it "should send a version bump to the source client as usual", ->
|
||||
@sourceClient.emit
|
||||
.calledWith("otUpdateApplied", v: @version, doc: @doc_id)
|
||||
.should.equal true
|
||||
|
||||
it "should not send anything to the other clients (they've already had the op)", ->
|
||||
for client in @otherClients
|
||||
client.emit
|
||||
.calledWith("otUpdateApplied")
|
||||
.should.equal false
|
||||
|
||||
describe "_processErrorFromDocumentUpdater", ->
|
||||
beforeEach ->
|
||||
@clients = [new MockClient(), new MockClient()]
|
||||
|
|
Loading…
Reference in a new issue