Change docLabelsUpdated socket event to broadcastDocLabels

This commit is contained in:
Shane Kilkelly 2017-06-12 13:06:56 +01:00
parent 234a2d0e21
commit ff4991284d
4 changed files with 5 additions and 7 deletions

View file

@ -20,7 +20,7 @@ module.exports = LabelsController =
if err? if err?
logger.err {project_id, doc_id, err}, "[LabelsController] error getting labels from doc" logger.err {project_id, doc_id, err}, "[LabelsController] error getting labels from doc"
return next(err) return next(err)
EditorRealTimeController.emitToRoom project_id, 'docLabelsUpdated', { EditorRealTimeController.emitToRoom project_id, 'broadcastDocLabels', {
docId: doc_id, labels: docLabels docId: doc_id, labels: docLabels
} }
res.json {projectId: project_id, docId: doc_id, labels: docLabels} res.json {projectId: project_id, docId: doc_id, labels: docLabels}

View file

@ -128,7 +128,8 @@ define [
ide.binaryFilesManager = new BinaryFilesManager(ide, $scope) ide.binaryFilesManager = new BinaryFilesManager(ide, $scope)
# Set up labels # 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 'entity:deleted', labels.onEntityDeleted
$scope.$on 'file:upload:complete', labels.fileUploadComplete $scope.$on 'file:upload:complete', labels.fileUploadComplete
$timeout () -> $timeout () ->
@ -179,7 +180,4 @@ define [
# User can append ?ft=somefeature to url to activate a feature toggle # User can append ?ft=somefeature to url to activate a feature toggle
ide.featureToggle = location?.search?.match(/^\?ft=(\w+)$/)?[1] ide.featureToggle = location?.search?.match(/^\?ft=(\w+)$/)?[1]
ide.socket.on 'docLabelsUpdated', (data) ->
$scope.$broadcast 'doc:labels:updated', data
angular.bootstrap(document.body, ["SharelatexApp"]) angular.bootstrap(document.body, ["SharelatexApp"])

View file

@ -10,7 +10,7 @@ define [
state: state state: state
} }
labels.onDocLabelsUpdated = (e, data) -> labels.onBroadcastDocLabels = (data) ->
if data.docId and data.labels if data.docId and data.labels
state.documents[data.docId] = data.labels state.documents[data.docId] = data.labels

View file

@ -92,7 +92,7 @@ describe 'LabelsController', ->
@EditorRealTimeController.emitToRoom.callCount.should.equal 1 @EditorRealTimeController.emitToRoom.callCount.should.equal 1
lastCall = @EditorRealTimeController.emitToRoom.lastCall lastCall = @EditorRealTimeController.emitToRoom.lastCall
expect(lastCall.args[0]).to.equal @projectId 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'] expect(lastCall.args[2]).to.have.all.keys ['docId', 'labels']
describe 'when LabelsHandler.getLabelsForDoc produces an error', -> describe 'when LabelsHandler.getLabelsForDoc produces an error', ->