From 43f6b9de7c4e6b5d751cff82a23b5ec788371ce1 Mon Sep 17 00:00:00 2001 From: James Allen Date: Mon, 9 Jan 2017 15:54:12 +0100 Subject: [PATCH] Inform other clients when we accept a change --- .../Features/Ranges/RangesController.coffee | 2 ++ .../controllers/ReviewPanelController.coffee | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/services/web/app/coffee/Features/Ranges/RangesController.coffee b/services/web/app/coffee/Features/Ranges/RangesController.coffee index 0c740cf892..4b2c1449a3 100644 --- a/services/web/app/coffee/Features/Ranges/RangesController.coffee +++ b/services/web/app/coffee/Features/Ranges/RangesController.coffee @@ -2,6 +2,7 @@ RangesManager = require "./RangesManager" logger = require "logger-sharelatex" UserInfoController = require "../User/UserInfoController" DocumentUpdaterHandler = require "../DocumentUpdater/DocumentUpdaterHandler" +EditorRealTimeController = require("../Editor/EditorRealTimeController") module.exports = RangesController = getAllRanges: (req, res, next) -> @@ -25,4 +26,5 @@ module.exports = RangesController = logger.log {project_id, doc_id, change_id}, "request to accept change" DocumentUpdaterHandler.acceptChange project_id, doc_id, change_id, (error) -> return next(error) if error? + EditorRealTimeController.emitToRoom project_id, "accept-change", doc_id, change_id, (err)-> res.send 204 diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 6fbbc6139d..6793c1fc81 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -34,6 +34,15 @@ define [ $scope.$apply() $timeout () -> $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 = {} @@ -124,13 +133,12 @@ define [ .success (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 - rangesTrackers[doc.id] ?= new RangesTracker() - rangesTrackers[doc.id].comments = doc.ranges?.comments or [] - rangesTrackers[doc.id].changes = doc.ranges?.changes or [] + rangesTracker = getChangeTracker(doc.id) + rangesTracker.comments = doc.ranges?.comments or [] + rangesTracker.changes = doc.ranges?.changes or [] updateEntries(doc.id) $scope.reviewPanel.overview.loading = false .error (error) -> - console.log "loading ranges errored", error $scope.reviewPanel.overview.loading = false updateEntries = (doc_id) ->