mirror of
https://github.com/strapi/strapi.git
synced 2025-08-31 04:03:50 +00:00
Merge pull request #3012 from strapi/fix/events
Remove synchronous way of sending event
This commit is contained in:
commit
a42c2a483c
@ -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' }] }]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user