From 0697510f3822698b25ddfe68e923bfeee3bec64c Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Fri, 21 Nov 2014 10:12:03 -0400 Subject: [PATCH] Refactor app:rm with async --- lib/actions/app.coffee | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/actions/app.coffee b/lib/actions/app.coffee index db9cfdc9..5a288057 100644 --- a/lib/actions/app.coffee +++ b/lib/actions/app.coffee @@ -1,4 +1,5 @@ _ = require('lodash') +async = require('async') device = require('../device/device') table = require('../table/table') server = require('../server/server') @@ -41,7 +42,17 @@ exports.restart = authHooks.failIfNotLoggedIn (id) -> throw error if error? exports.remove = authHooks.failIfNotLoggedIn (id) -> - widgets.confirmRemoval 'application', (error, confirmed) -> - return if not confirmed - applicationModel.remove(id).catch (error) -> - throw error if error? + async.waterfall [ + + (callback) -> + widgets.confirmRemoval('application', callback) + + (confirmed, callback) -> + return callback() if not confirmed + + applicationModel.remove(id).then -> + return callback() + .catch(callback) + + ], (error) -> + throw error if error?