mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Recover tracked changes after a disconnect
This commit is contained in:
parent
a42cc48be8
commit
2052ee63a3
3 changed files with 32 additions and 4 deletions
|
@ -252,9 +252,7 @@ define [
|
|||
return callback(error) if error?
|
||||
@joined = true
|
||||
@doc.catchUp( updates )
|
||||
# TODO: Worry about whether these ranges are consistent with the doc still
|
||||
@ranges?.changes = ranges?.changes
|
||||
@ranges?.comments = ranges?.comments
|
||||
@_catchUpRanges( ranges?.changes, ranges?.comments )
|
||||
callback()
|
||||
else
|
||||
@ide.socket.emit 'joinDoc', @doc_id, (error, docLines, version, updates, ranges) =>
|
||||
|
@ -341,6 +339,7 @@ define [
|
|||
track_changes_as = null
|
||||
remote_op = msg?
|
||||
if msg?.meta?.tc?
|
||||
old_id_seed = @ranges.getIdSeed()
|
||||
@ranges.setIdSeed(msg.meta.tc)
|
||||
if remote_op and msg.meta?.tc
|
||||
track_changes_as = msg.meta.user_id
|
||||
|
@ -349,3 +348,20 @@ define [
|
|||
@ranges.track_changes = track_changes_as?
|
||||
for op in ops
|
||||
@ranges.applyOp op, { user_id: track_changes_as }
|
||||
if old_id_seed?
|
||||
@ranges.setIdSeed(old_id_seed)
|
||||
|
||||
_catchUpRanges: (changes = [], comments = []) ->
|
||||
# We've just been given the current server's ranges, but need to apply any local ops we have.
|
||||
# Reset to the server state then apply our local ops again.
|
||||
@ranges.emit "clear"
|
||||
@ranges.changes = changes
|
||||
@ranges.comments = comments
|
||||
@ranges.track_changes = @doc.track_changes
|
||||
for op in @doc.getInflightOp() or []
|
||||
@ranges.setIdSeed(@doc.track_changes_id_seeds.inflight)
|
||||
@ranges.applyOp(op)
|
||||
for op in @doc.getPendingOp() or []
|
||||
@ranges.setIdSeed(@doc.track_changes_id_seeds.pending)
|
||||
@ranges.applyOp(op)
|
||||
@ranges.emit "redraw"
|
||||
|
|
|
@ -59,6 +59,7 @@ define [
|
|||
@recalculateReviewEntriesScreenPositions()
|
||||
|
||||
onChangeSession = (e) =>
|
||||
@clearAnnotations()
|
||||
@redrawAnnotations()
|
||||
|
||||
bindToAce = () =>
|
||||
|
@ -128,6 +129,18 @@ define [
|
|||
sl_console.log "[comment:removed]", comment
|
||||
setTimeout () => @_onCommentRemoved(comment)
|
||||
|
||||
@rangesTracker.on "clear", () =>
|
||||
@clearAnnotations()
|
||||
@rangesTracker.on "redraw", () =>
|
||||
@redrawAnnotations()
|
||||
|
||||
clearAnnotations: () ->
|
||||
session = @editor.getSession()
|
||||
for change_id, markers of @changeIdToMarkerIdMap
|
||||
for marker_name, marker_id of markers
|
||||
session.removeMarker marker_id
|
||||
@changeIdToMarkerIdMap = {}
|
||||
|
||||
redrawAnnotations: () ->
|
||||
for change in @rangesTracker.changes
|
||||
if change.op.i?
|
||||
|
|
|
@ -320,7 +320,6 @@ define [
|
|||
ide.editorManager.openDocId(doc_id, { gotoOffset: entry.offset })
|
||||
|
||||
$scope.toggleTrackChanges = (value) ->
|
||||
console.log "Toggling track changes", value
|
||||
$scope.editor.wantTrackChanges = value
|
||||
$http.post "/project/#{$scope.project_id}/track_changes", {_csrf: window.csrfToken, on: value}
|
||||
|
||||
|
|
Loading…
Reference in a new issue