Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func addConnection(targetUser:SparksUser) {
- connectionButton.setTitle("Pending", forState: UIControlState.Normal)
- connectionButton.enabled = false
- let currentUser = SparksUser.currentUser()!
- //
- // var areConnections = Connection.query()
- // areConnections?.whereKey("currentUser", equalTo: SparksUser.currentUser()!)
- // areConnections?.whereKey("targetUser", equalTo: newConnection)
- // areConnections?.countObjectsInBackgroundWithBlock({ (count, error) -> Void in
- // if error != nil {
- // self.connectionButton.setTitle("Request", forState: UIControlState.Normal)
- // println(error)
- // return
- // }
- //
- // if count > 0 {
- // // They are already connected
- // println("They are already connections")
- // } else {
- // add connection
- var connection = Connection()
- var notification = Notification()
- connection.currentUser = currentUser
- connection.targetUser = targetUser
- connection.status = .Requested
- notification.fromUser = currentUser
- notification.targetUser = targetUser
- notification.title = "Connection Request From:"
- notification.text = "\(currentUser.username!)"
- notification.read = false
- // notification.saveInBackgroundWithBlock({ (success, error) -> Void in
- // if error != nil {
- // println("This was the error: \(error)")
- // }
- // })
- notification.saveInBackgroundWithBlock(nil)
- connection.saveInBackgroundWithBlock(nil)
- println("connecting \(connection.currentUser) and \(connection.targetUser)")
- // }
- self.connectionStatus = ConnectionRequestStatus.Requested
- self.updateConnectionStatus()
- // })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement