overleaf/services/web/app/coffee/Features/Project/OlProjectGetter.coffee
Alasdair Smith 8735261022 Extract V1 projects fetch to integration module
OlProjectGetter now just detects if integration module is loaded and proxies
to integration module. If module not loaded, it just bails
2017-11-20 11:23:02 +00:00

22 lines
929 B
CoffeeScript

fs = require 'fs'
path = require 'path'
logger = require 'logger-sharelatex'
INTEGRATION_MODULE_PATH = path.resolve(__dirname, '../../../../modules/overleaf-integration-web-module')
module.exports = OlProjectGetter =
integrationModuleExists: (callback = (error, stats) ->) ->
fs.stat INTEGRATION_MODULE_PATH, (error, stats) ->
if error? or !stats.isDirectory()
return callback(false)
return callback(true)
findAllUsersProjects: (userId, callback = (error, projects) ->) ->
OlProjectGetter.integrationModuleExists (exists) ->
if exists
logger.log {exists}, "integration module does exist, loading V1 projects"
V1ProjectListGetter = require(path.join(INTEGRATION_MODULE_PATH, 'app/coffee/ProjectList/ProjectListGetter'))
V1ProjectListGetter.findAllUsersProjects(userId, callback)
else
logger.log {exists}, "integration modules doesn't exists, not loading V1 projects"
return callback()