mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Flush project before getting all project labels
This commit is contained in:
parent
bd6133aadb
commit
a3dbb16e50
2 changed files with 7 additions and 6 deletions
|
@ -8,16 +8,16 @@ module.exports = LabelsHandler =
|
||||||
/\\label\{([^\}\n\\]{0,80})\}/g
|
/\\label\{([^\}\n\\]{0,80})\}/g
|
||||||
|
|
||||||
getAllLabelsForProject: (projectId, callback=(err, projectLabels)->) ->
|
getAllLabelsForProject: (projectId, callback=(err, projectLabels)->) ->
|
||||||
ProjectEntityHandler.getAllDocs projectId, (err, docs) ->
|
DocumentUpdaterHandler.flushProjectToMongo projectId, (err) ->
|
||||||
if err?
|
if err?
|
||||||
return callback(err)
|
return callback(err)
|
||||||
projectLabels = LabelsHandler.extractLabelsFromProjectDocs docs
|
ProjectEntityHandler.getAllDocs projectId, (err, docs) ->
|
||||||
callback(null, projectLabels)
|
if err?
|
||||||
|
return callback(err)
|
||||||
|
projectLabels = LabelsHandler.extractLabelsFromProjectDocs docs
|
||||||
|
callback(null, projectLabels)
|
||||||
|
|
||||||
getLabelsForDoc: (projectId, docId, callback=(err, docLabels)->) ->
|
getLabelsForDoc: (projectId, docId, callback=(err, docLabels)->) ->
|
||||||
# Flush doc first, because this action is often performed while
|
|
||||||
# a document is being edited by the client. By contrast,
|
|
||||||
# `getAllLabelsForProject` is called only when a project/editor is loaded
|
|
||||||
DocumentUpdaterHandler.flushDocToMongo projectId, docId, (err) ->
|
DocumentUpdaterHandler.flushDocToMongo projectId, docId, (err) ->
|
||||||
if err?
|
if err?
|
||||||
return callback(err)
|
return callback(err)
|
||||||
|
|
|
@ -105,6 +105,7 @@ describe 'LabelsHandler', ->
|
||||||
'doc_one': {lines: ['\\label{aaa}']}
|
'doc_one': {lines: ['\\label{aaa}']}
|
||||||
}
|
}
|
||||||
@fakeLabels = ['aaa']
|
@fakeLabels = ['aaa']
|
||||||
|
@DocumentUpdaterHandler.flushProjectToMongo = sinon.stub().callsArgWith(1, null)
|
||||||
@ProjectEntityHandler.getAllDocs = sinon.stub().callsArgWith(1, null, @fakeDocs)
|
@ProjectEntityHandler.getAllDocs = sinon.stub().callsArgWith(1, null, @fakeDocs)
|
||||||
@LabelsHandler.extractLabelsFromProjectDocs = sinon.stub().returns(@fakeLabels)
|
@LabelsHandler.extractLabelsFromProjectDocs = sinon.stub().returns(@fakeLabels)
|
||||||
@call = (callback) =>
|
@call = (callback) =>
|
||||||
|
|
Loading…
Reference in a new issue