mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Use new ranges tracker method to get N changes at once; small refactor.
This commit is contained in:
parent
7bb5d65b52
commit
f4e46bb2f9
1 changed files with 27 additions and 34 deletions
|
@ -27,16 +27,16 @@ define [
|
||||||
@selectLineIfNoSelection()
|
@selectLineIfNoSelection()
|
||||||
|
|
||||||
@$scope.$on "change:accept", (e, change_id) =>
|
@$scope.$on "change:accept", (e, change_id) =>
|
||||||
@acceptChangeId(change_id)
|
@acceptChangeIds([ change_id ])
|
||||||
|
|
||||||
@$scope.$on "change:reject", (e, change_id) =>
|
@$scope.$on "change:reject", (e, change_id) =>
|
||||||
@rejectChangeId(change_id)
|
@rejectChangeIds([ change_id ])
|
||||||
|
|
||||||
@$scope.$on "change:bulk-accept", (e, change_ids) =>
|
@$scope.$on "change:bulk-accept", (e, change_ids) =>
|
||||||
@bulkAcceptChangeIds(change_ids)
|
@acceptChangeIds(change_ids)
|
||||||
|
|
||||||
@$scope.$on "change:bulk-reject", (e, change_ids) =>
|
@$scope.$on "change:bulk-reject", (e, change_ids) =>
|
||||||
@bulkRejectChangeIds(change_ids)
|
@rejectChangeIds(change_ids)
|
||||||
|
|
||||||
@$scope.$on "comment:remove", (e, comment_id) =>
|
@$scope.$on "comment:remove", (e, comment_id) =>
|
||||||
@removeCommentId(comment_id)
|
@removeCommentId(comment_id)
|
||||||
|
@ -213,14 +213,15 @@ define [
|
||||||
if @editor.selection.isEmpty()
|
if @editor.selection.isEmpty()
|
||||||
@editor.selection.selectLine()
|
@editor.selection.selectLine()
|
||||||
|
|
||||||
acceptChangeId: (change_id) ->
|
acceptChangeIds: (change_ids) ->
|
||||||
@rangesTracker.removeChangeId(change_id)
|
@rangesTracker.removeChangeIds(change_ids)
|
||||||
@updateAnnotations()
|
@updateAnnotations()
|
||||||
|
|
||||||
rejectChangeId: (change_id) ->
|
rejectChangeIds: (change_ids) ->
|
||||||
change = @rangesTracker.getChange(change_id)
|
changes = @rangesTracker.getChanges(change_ids)
|
||||||
return if !change?
|
return if changes.length == 0
|
||||||
session = @editor.getSession()
|
session = @editor.getSession()
|
||||||
|
for change in changes
|
||||||
if change.op.d?
|
if change.op.d?
|
||||||
content = change.op.d
|
content = change.op.d
|
||||||
position = @_shareJsOffsetToAcePosition(change.op.p)
|
position = @_shareJsOffsetToAcePosition(change.op.p)
|
||||||
|
@ -239,14 +240,6 @@ define [
|
||||||
else
|
else
|
||||||
throw new Error("unknown change: #{JSON.stringify(change)}")
|
throw new Error("unknown change: #{JSON.stringify(change)}")
|
||||||
|
|
||||||
bulkAcceptChangeIds: (change_ids) ->
|
|
||||||
@rangesTracker.removeChangeIds(change_ids)
|
|
||||||
@updateAnnotations()
|
|
||||||
|
|
||||||
bulkRejectChangeIds: (change_ids) ->
|
|
||||||
for change_id in change_ids
|
|
||||||
@rejectChangeId change_id
|
|
||||||
|
|
||||||
removeCommentId: (comment_id) ->
|
removeCommentId: (comment_id) ->
|
||||||
@rangesTracker.removeCommentId(comment_id)
|
@rangesTracker.removeCommentId(comment_id)
|
||||||
@updateAnnotations()
|
@updateAnnotations()
|
||||||
|
|
Loading…
Reference in a new issue