mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Merge pull request #28945 from overleaf/mj-tear-down-server-side-referencing
[web] Tear down server side referencing GitOrigin-RevId: 37feac39cc7bf219a2cbc463191163534434f267
This commit is contained in:
committed by
Copybot
parent
45ad16445f
commit
43a80ef8a5
@@ -1,63 +1,20 @@
|
||||
/* eslint-disable
|
||||
max-len,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
import ReferencesHandler from './ReferencesHandler.mjs'
|
||||
import EditorRealTimeController from '../Editor/EditorRealTimeController.js'
|
||||
import { OError } from '../Errors/Errors.js'
|
||||
|
||||
let ReferencesController
|
||||
|
||||
export default ReferencesController = {
|
||||
export default {
|
||||
indexAll(req, res, next) {
|
||||
const projectId = req.params.Project_id
|
||||
const { shouldBroadcast, clientId } = req.body
|
||||
return ReferencesHandler.indexAll(projectId, function (error, data) {
|
||||
if (error) {
|
||||
OError.tag(error, 'failed to index references', { projectId })
|
||||
return next(error)
|
||||
}
|
||||
return ReferencesController._handleIndexResponse(
|
||||
req,
|
||||
res,
|
||||
projectId,
|
||||
shouldBroadcast,
|
||||
true,
|
||||
data,
|
||||
clientId
|
||||
)
|
||||
})
|
||||
},
|
||||
|
||||
_handleIndexResponse(
|
||||
req,
|
||||
res,
|
||||
projectId,
|
||||
shouldBroadcast,
|
||||
isAllDocs,
|
||||
data,
|
||||
clientId
|
||||
) {
|
||||
if (data == null || data.keys == null) {
|
||||
return res.json({ projectId, keys: [] })
|
||||
}
|
||||
// We've migrated to client side indexing, so we only use the message for
|
||||
// broadcasting that the clients need to re-index.
|
||||
if (shouldBroadcast) {
|
||||
EditorRealTimeController.emitToRoom(
|
||||
projectId,
|
||||
'references:keys:updated',
|
||||
data.keys,
|
||||
isAllDocs,
|
||||
[],
|
||||
true,
|
||||
clientId
|
||||
)
|
||||
}
|
||||
return res.json(data)
|
||||
res.json({ projectId, keys: [] })
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user