소스 검색

Delay flushes performed after getting an op acknowledgement as well

James Allen 11 년 전
부모
커밋
87d625b5e0
1개의 변경된 파일과 5개의 추가작업 그리고 4개의 파일을 삭제
  1. 5 4
      services/web/public/coffee/ide/editor/sharejs/vendor/client/doc.coffee

+ 5 - 4
services/web/public/coffee/ide/editor/sharejs/vendor/client/doc.coffee

@@ -200,7 +200,7 @@ class Doc
         callback null, oldInflightOp for callback in @inflightCallbacks
 
       # Send the next op.
-      @flush()
+      @delayedFlush()
 
     else if msg.op
       # We got a new op from the server.
@@ -247,7 +247,7 @@ class Doc
   # Only one op can be in-flight at a time, so if an op is already on its way then
   # this method does nothing.
   flush: =>
-    delete @flushTimeout
+    @flushTimeout = null
     #console.log "CALLED FLUSH"
 
     return unless @connection.state == 'ok' and @inflightOp == null and @pendingOp != null
@@ -279,8 +279,9 @@ class Doc
 
     @emit 'change', op
 
-    # A timeout is used so if the user sends multiple ops at the same time, they'll be composed
-    # & sent together.
+    @delayedFlush()
+
+  delayedFlush: () ->
     if !@flushTimeout?
         @flushTimeout = setTimeout @flush, @_flushDelay || 0