mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-25 06:31:52 +00:00
Inform other clients when we accept a change
This commit is contained in:
parent
7e33d1a24e
commit
43f6b9de7c
2 changed files with 14 additions and 4 deletions
|
@ -2,6 +2,7 @@ RangesManager = require "./RangesManager"
|
||||||
logger = require "logger-sharelatex"
|
logger = require "logger-sharelatex"
|
||||||
UserInfoController = require "../User/UserInfoController"
|
UserInfoController = require "../User/UserInfoController"
|
||||||
DocumentUpdaterHandler = require "../DocumentUpdater/DocumentUpdaterHandler"
|
DocumentUpdaterHandler = require "../DocumentUpdater/DocumentUpdaterHandler"
|
||||||
|
EditorRealTimeController = require("../Editor/EditorRealTimeController")
|
||||||
|
|
||||||
module.exports = RangesController =
|
module.exports = RangesController =
|
||||||
getAllRanges: (req, res, next) ->
|
getAllRanges: (req, res, next) ->
|
||||||
|
@ -25,4 +26,5 @@ module.exports = RangesController =
|
||||||
logger.log {project_id, doc_id, change_id}, "request to accept change"
|
logger.log {project_id, doc_id, change_id}, "request to accept change"
|
||||||
DocumentUpdaterHandler.acceptChange project_id, doc_id, change_id, (error) ->
|
DocumentUpdaterHandler.acceptChange project_id, doc_id, change_id, (error) ->
|
||||||
return next(error) if error?
|
return next(error) if error?
|
||||||
|
EditorRealTimeController.emitToRoom project_id, "accept-change", doc_id, change_id, (err)->
|
||||||
res.send 204
|
res.send 204
|
||||||
|
|
|
@ -35,6 +35,15 @@ define [
|
||||||
$timeout () ->
|
$timeout () ->
|
||||||
$scope.$broadcast "review-panel:layout"
|
$scope.$broadcast "review-panel:layout"
|
||||||
|
|
||||||
|
ide.socket.on "accept-change", (doc_id, change_id) ->
|
||||||
|
console.log "Got remote accept change", doc_id, change_id
|
||||||
|
if doc_id != $scope.editor.open_doc_id
|
||||||
|
getChangeTracker(doc_id).removeChangeId(change_id)
|
||||||
|
else
|
||||||
|
$scope.$broadcast "change:accept", change_id
|
||||||
|
updateEntries(doc_id)
|
||||||
|
$scope.$apply () ->
|
||||||
|
|
||||||
rangesTrackers = {}
|
rangesTrackers = {}
|
||||||
|
|
||||||
getDocEntries = (doc_id) ->
|
getDocEntries = (doc_id) ->
|
||||||
|
@ -124,13 +133,12 @@ define [
|
||||||
.success (docs) ->
|
.success (docs) ->
|
||||||
for doc in docs
|
for doc in docs
|
||||||
if doc.id != $scope.editor.open_doc_id # this is kept up to date in real-time, don't overwrite
|
if doc.id != $scope.editor.open_doc_id # this is kept up to date in real-time, don't overwrite
|
||||||
rangesTrackers[doc.id] ?= new RangesTracker()
|
rangesTracker = getChangeTracker(doc.id)
|
||||||
rangesTrackers[doc.id].comments = doc.ranges?.comments or []
|
rangesTracker.comments = doc.ranges?.comments or []
|
||||||
rangesTrackers[doc.id].changes = doc.ranges?.changes or []
|
rangesTracker.changes = doc.ranges?.changes or []
|
||||||
updateEntries(doc.id)
|
updateEntries(doc.id)
|
||||||
$scope.reviewPanel.overview.loading = false
|
$scope.reviewPanel.overview.loading = false
|
||||||
.error (error) ->
|
.error (error) ->
|
||||||
console.log "loading ranges errored", error
|
|
||||||
$scope.reviewPanel.overview.loading = false
|
$scope.reviewPanel.overview.loading = false
|
||||||
|
|
||||||
updateEntries = (doc_id) ->
|
updateEntries = (doc_id) ->
|
||||||
|
|
Loading…
Reference in a new issue