mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-09 03:50:49 +00:00
DRY up
This commit is contained in:
parent
24f44889a7
commit
b33929fa83
1 changed files with 14 additions and 22 deletions
|
@ -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) =>
|
||||
|
|
Loading…
Add table
Reference in a new issue