From ff4991284dfdb26384c7355d83e2d1d65e7c836c Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Mon, 12 Jun 2017 13:06:56 +0100 Subject: [PATCH] Change `docLabelsUpdated` socket event to `broadcastDocLabels` --- .../web/app/coffee/Features/Labels/LabelsController.coffee | 2 +- services/web/public/coffee/ide.coffee | 6 ++---- services/web/public/coffee/services/labels.coffee | 2 +- .../UnitTests/coffee/Labels/LabelsControllerTests.coffee | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/services/web/app/coffee/Features/Labels/LabelsController.coffee b/services/web/app/coffee/Features/Labels/LabelsController.coffee index 40f4081da0..b3c56cc79c 100644 --- a/services/web/app/coffee/Features/Labels/LabelsController.coffee +++ b/services/web/app/coffee/Features/Labels/LabelsController.coffee @@ -20,7 +20,7 @@ module.exports = LabelsController = if err? logger.err {project_id, doc_id, err}, "[LabelsController] error getting labels from doc" return next(err) - EditorRealTimeController.emitToRoom project_id, 'docLabelsUpdated', { + EditorRealTimeController.emitToRoom project_id, 'broadcastDocLabels', { docId: doc_id, labels: docLabels } res.json {projectId: project_id, docId: doc_id, labels: docLabels} diff --git a/services/web/public/coffee/ide.coffee b/services/web/public/coffee/ide.coffee index 8f2c63ec21..997dc43ba4 100644 --- a/services/web/public/coffee/ide.coffee +++ b/services/web/public/coffee/ide.coffee @@ -128,7 +128,8 @@ define [ ide.binaryFilesManager = new BinaryFilesManager(ide, $scope) # Set up labels - $scope.$on 'doc:labels:updated', labels.onDocLabelsUpdated + ide.socket.on 'broadcastDocLabels', (data) -> + labels.onBroadcastDocLabels(data) $scope.$on 'entity:deleted', labels.onEntityDeleted $scope.$on 'file:upload:complete', labels.fileUploadComplete $timeout () -> @@ -179,7 +180,4 @@ define [ # User can append ?ft=somefeature to url to activate a feature toggle ide.featureToggle = location?.search?.match(/^\?ft=(\w+)$/)?[1] - ide.socket.on 'docLabelsUpdated', (data) -> - $scope.$broadcast 'doc:labels:updated', data - angular.bootstrap(document.body, ["SharelatexApp"]) diff --git a/services/web/public/coffee/services/labels.coffee b/services/web/public/coffee/services/labels.coffee index 0c18ce277f..130cc0e52e 100644 --- a/services/web/public/coffee/services/labels.coffee +++ b/services/web/public/coffee/services/labels.coffee @@ -10,7 +10,7 @@ define [ state: state } - labels.onDocLabelsUpdated = (e, data) -> + labels.onBroadcastDocLabels = (data) -> if data.docId and data.labels state.documents[data.docId] = data.labels diff --git a/services/web/test/UnitTests/coffee/Labels/LabelsControllerTests.coffee b/services/web/test/UnitTests/coffee/Labels/LabelsControllerTests.coffee index af19dceb38..e695139071 100644 --- a/services/web/test/UnitTests/coffee/Labels/LabelsControllerTests.coffee +++ b/services/web/test/UnitTests/coffee/Labels/LabelsControllerTests.coffee @@ -92,7 +92,7 @@ describe 'LabelsController', -> @EditorRealTimeController.emitToRoom.callCount.should.equal 1 lastCall = @EditorRealTimeController.emitToRoom.lastCall expect(lastCall.args[0]).to.equal @projectId - expect(lastCall.args[1]).to.equal 'docLabelsUpdated' + expect(lastCall.args[1]).to.equal 'broadcastDocLabels' expect(lastCall.args[2]).to.have.all.keys ['docId', 'labels'] describe 'when LabelsHandler.getLabelsForDoc produces an error', ->