mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Use a single accept changes method.
This commit is contained in:
parent
f25db3ff64
commit
3ced808411
2 changed files with 4 additions and 20 deletions
|
@ -137,29 +137,13 @@ module.exports = DocumentUpdaterHandler =
|
||||||
logger.error project_id:project_id, doc_id:doc_id, url: url, "doc updater returned a non-success status code: #{res.statusCode}"
|
logger.error project_id:project_id, doc_id:doc_id, url: url, "doc updater returned a non-success status code: #{res.statusCode}"
|
||||||
callback new Error("doc updater returned a non-success status code: #{res.statusCode}")
|
callback new Error("doc updater returned a non-success status code: #{res.statusCode}")
|
||||||
|
|
||||||
acceptChange: (project_id, doc_id, change_id, callback = (error) ->) ->
|
acceptChanges: (project_id, doc_id, change_ids = [], callback = (error) ->) ->
|
||||||
timer = new metrics.Timer("accept-change")
|
timer = new metrics.Timer("accept-changes")
|
||||||
url = "#{settings.apis.documentupdater.url}/project/#{project_id}/doc/#{doc_id}/change/#{change_id}/accept"
|
|
||||||
logger.log {project_id, doc_id, change_id}, "accepting change in document updater"
|
|
||||||
request.post url, (error, res, body)->
|
|
||||||
timer.done()
|
|
||||||
if error?
|
|
||||||
logger.error {err:error, project_id, doc_id, change_id}, "error accepting change in doc updater"
|
|
||||||
return callback(error)
|
|
||||||
if res.statusCode >= 200 and res.statusCode < 300
|
|
||||||
logger.log {project_id, doc_id, change_id}, "accepted change in document updater"
|
|
||||||
return callback(null)
|
|
||||||
else
|
|
||||||
logger.error {project_id, doc_id, change_id}, "doc updater returned a non-success status code: #{res.statusCode}"
|
|
||||||
callback new Error("doc updater returned a non-success status code: #{res.statusCode}")
|
|
||||||
|
|
||||||
bulkAcceptChanges: (project_id, doc_id, change_ids, callback = (error) ->) ->
|
|
||||||
timer = new metrics.Timer("bulk-accept-changes")
|
|
||||||
reqSettings =
|
reqSettings =
|
||||||
url: "#{settings.apis.documentupdater.url}/project/#{project_id}/doc/#{doc_id}/change/accept"
|
url: "#{settings.apis.documentupdater.url}/project/#{project_id}/doc/#{doc_id}/change/accept"
|
||||||
json:
|
json:
|
||||||
change_ids: change_ids
|
change_ids: change_ids
|
||||||
logger.log {project_id, doc_id }, "bulk accepting #{ change_ids.length } changes"
|
logger.log {project_id, doc_id }, "accepting #{ change_ids.length } changes"
|
||||||
request.post reqSettings, (error, res, body)->
|
request.post reqSettings, (error, res, body)->
|
||||||
timer.done()
|
timer.done()
|
||||||
if error?
|
if error?
|
||||||
|
|
|
@ -78,7 +78,7 @@ define [
|
||||||
updateEntries(doc_id)
|
updateEntries(doc_id)
|
||||||
$scope.$apply () ->
|
$scope.$apply () ->
|
||||||
|
|
||||||
ide.socket.on "bulk-accept-changes", (doc_id, change_ids) ->
|
ide.socket.on "accept-changes", (doc_id, change_ids) ->
|
||||||
if doc_id != $scope.editor.open_doc_id
|
if doc_id != $scope.editor.open_doc_id
|
||||||
for change_id in change_ids
|
for change_id in change_ids
|
||||||
getChangeTracker(doc_id).removeChangeId(change_id)
|
getChangeTracker(doc_id).removeChangeId(change_id)
|
||||||
|
|
Loading…
Reference in a new issue