overleaf/services/web/public/coffee/ide/share/services/projectMembers.coffee
2014-07-08 12:02:26 +01:00

30 lines
No EOL
631 B
CoffeeScript

define [
"base"
], (App) ->
App.factory "projectMembers", ["ide", "$q", (ide, $q) ->
return {
removeMember: (member) ->
deferred = $q.defer()
ide.socket.emit "removeUserFromProject", member._id, (error) =>
if error?
return deferred.reject(error)
deferred.resolve()
return deferred.promise
addMember: (email, privileges) ->
deferred = $q.defer()
ide.socket.emit "addUserToProject", email, privileges, (error, user) =>
if error?
return deferred.reject(error)
if !user
deferred.reject()
else
deferred.resolve(user)
return deferred.promise
}
]