|
|
@@ -256,17 +256,7 @@ define [
|
|
|
return callback(error) if error?
|
|
|
@joined = true
|
|
|
@doc.catchUp( updates )
|
|
|
-
|
|
|
- if ranges?.changes
|
|
|
- changes = for change in ranges.changes
|
|
|
- change.op.i = decodeURIComponent(escape(change.op.i)) if change.op.i
|
|
|
- change.op.d = decodeURIComponent(escape(change.op.d)) if change.op.d
|
|
|
- change
|
|
|
- if ranges?.comments
|
|
|
- comments = for comment in ranges.comments
|
|
|
- comment.op.c = decodeURIComponent(escape(comment.op.c))
|
|
|
- comment
|
|
|
-
|
|
|
+ { changes, comments } = @_decodeRanges(ranges)
|
|
|
@_catchUpRanges( changes, comments )
|
|
|
callback()
|
|
|
else
|
|
|
@@ -274,21 +264,23 @@ define [
|
|
|
return callback(error) if error?
|
|
|
@joined = true
|
|
|
@doc = new ShareJsDoc @doc_id, docLines, version, @ide.socket
|
|
|
-
|
|
|
- if ranges?.changes
|
|
|
- changes = for change in ranges.changes
|
|
|
- change.op.i = decodeURIComponent(escape(change.op.i)) if change.op.i
|
|
|
- change.op.d = decodeURIComponent(escape(change.op.d)) if change.op.d
|
|
|
- change
|
|
|
- if ranges?.comments
|
|
|
- comments = for comment in ranges.comments
|
|
|
- comment.op.c = decodeURIComponent(escape(comment.op.c))
|
|
|
- comment
|
|
|
-
|
|
|
+ { changes, comments } = @_decodeRanges(ranges)
|
|
|
@ranges = new RangesTracker(changes, comments)
|
|
|
@_bindToShareJsDocEvents()
|
|
|
callback()
|
|
|
|
|
|
+ _decodeRanges: (ranges) ->
|
|
|
+ if ranges?.changes
|
|
|
+ changes = for change in ranges.changes
|
|
|
+ change.op.i = decodeURIComponent(escape(change.op.i)) if change.op.i
|
|
|
+ change.op.d = decodeURIComponent(escape(change.op.d)) if change.op.d
|
|
|
+ change
|
|
|
+ if ranges?.comments
|
|
|
+ comments = for comment in ranges.comments
|
|
|
+ comment.op.c = decodeURIComponent(escape(comment.op.c))
|
|
|
+ comment
|
|
|
+ { changes, comments }
|
|
|
+
|
|
|
_leaveDoc: (callback = (error) ->) ->
|
|
|
sl_console.log '[_leaveDoc] Sending leaveDoc request'
|
|
|
@ide.socket.emit 'leaveDoc', @doc_id, (error) =>
|