Merge branch 'ja-track-changes' of github.com:sharelatex/web-sharelatex into ja-track-changes

This commit is contained in:
Paulo Reis 2017-01-12 16:49:56 +00:00
commit 3d5691ddaf
3 changed files with 32 additions and 4 deletions

View file

@ -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"

View file

@ -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?

View file

@ -330,7 +330,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}