Use a single accept changes method.

This commit is contained in:
Paulo Reis 2017-05-05 15:19:31 +01:00
parent f25db3ff64
commit 3ced808411
2 changed files with 4 additions and 20 deletions

View file

@ -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}"
callback new Error("doc updater returned a non-success status code: #{res.statusCode}")
acceptChange: (project_id, doc_id, change_id, callback = (error) ->) ->
timer = new metrics.Timer("accept-change")
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")
acceptChanges: (project_id, doc_id, change_ids = [], callback = (error) ->) ->
timer = new metrics.Timer("accept-changes")
reqSettings =
url: "#{settings.apis.documentupdater.url}/project/#{project_id}/doc/#{doc_id}/change/accept"
json:
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)->
timer.done()
if error?

View file

@ -78,7 +78,7 @@ define [
updateEntries(doc_id)
$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
for change_id in change_ids
getChangeTracker(doc_id).removeChangeId(change_id)