From 4ff11cd136a4fb98483f837e2cebc741380dfe76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Zanghelini?= Date: Wed, 5 Jul 2017 17:29:08 -0300 Subject: [PATCH] Remove async waterfall --- src/controllers/index.js | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/controllers/index.js b/src/controllers/index.js index 6b472fb42f..ed35825f15 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -297,19 +297,13 @@ Controllers.composePost = function (req, res) { if (body.tid) { data.tid = body.tid; - async.waterfall([ - function (next) { - topics.reply(data, next); - }, - function (postData) { - user.updateOnlineUsers(postData.uid); - - res.redirect(nconf.get('relative_path') + '/post/' + postData.pid); - }, - ], function (err) { + topics.reply(data, function (err, result) { if (err) { return helpers.noScriptErrors(req, res, err.message, 400); } + user.updateOnlineUsers(result.uid); + + res.redirect(nconf.get('relative_path') + '/post/' + result.pid); }); } else if (body.cid) { data.cid = body.cid; @@ -317,17 +311,12 @@ Controllers.composePost = function (req, res) { data.tags = []; data.thumb = ''; - async.waterfall([ - function (next) { - topics.post(data, next); - }, - function (result) { - res.redirect(nconf.get('relative_path') + '/topic/' + result.topicData.slug); - }, - ], function (err) { + topics.post(data, function (err, result) { if (err) { return helpers.noScriptErrors(req, res, err.message, 400); } + + res.redirect(nconf.get('relative_path') + '/topic/' + result.topicData.slug); }); } };