Refactor app:rm with async

This commit is contained in:
Juan Cruz Viotti 2014-11-21 10:12:03 -04:00
parent 37c68118db
commit 0697510f38

View File

@ -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?