Remove synchronous way of sending event

This commit is contained in:
Aurélien Georget 2019-03-21 11:02:52 +01:00
parent 81ed8d0fb2
commit e40a7ad878

View File

@ -78,17 +78,15 @@ module.exports = {
try {
fs.writeFileSync(modelFilePath, JSON.stringify(modelJSON, null, 2), 'utf8');
const response = () => {
ctx.send({ ok: true });
strapi.reload();
};
if (_.isEmpty(strapi.api)) {
strapi.emit('didCreateFirstContentType', response);
strapi.emit('didCreateFirstContentType');
} else {
strapi.emit('didCreateContentType', response);
strapi.emit('didCreateContentType');
}
ctx.send({ ok: true });
setImmediate(() => strapi.reload());
} catch (e) {
strapi.emit('didNotCreateContentType', e);
return ctx.badRequest(null, [{ messages: [{ id: 'request.error.model.write' }] }]);