refactored updateClientPosition to use async

This commit is contained in:
Henry Oswald 2014-07-14 12:58:55 +01:00
parent 5093820a5f
commit 2b2b995340

View file

@ -113,16 +113,14 @@ module.exports = EditorController =
), 500
updateClientPosition: (client, cursorData, callback = (error) ->) ->
client.get "project_id", (error, project_id) ->
return callback(error) if error?
client.get "first_name", (error, first_name) ->
return callback(error) if error?
client.get "last_name", (error, last_name) ->
return callback(error) if error?
client.get "email", (error, email) ->
return callback(error) if error?
client.get "user_id", (error, user_id) ->
return callback(error) if error?
async.parallel {
project_id: (cb)-> client.get "project_id", cb
first_name: (cb)-> client.get "first_name", cb
last_name: (cb)-> client.get "last_name", cb
email: (cb)-> client.get "email", cb
user_id: (cb)-> client.get "user_id", cb
}, (err, results)->
{first_name, last_name, user_id, email, project_id} = results
cursorData.id = client.id
cursorData.user_id = user_id if user_id?
cursorData.email = email if email?