mirror of
https://github.com/oonyeje/Get-Hip.git
synced 2025-12-25 11:47:41 +00:00
friendRequest system working just need to touch up
This commit is contained in:
parent
e9faaf69fd
commit
ea10811a37
@ -68,16 +68,18 @@ class FriendDataSource{
|
||||
var newFriend: FriendData = FriendData(display: userName, status: requestStatus)
|
||||
//print(userName)
|
||||
self.dataSource.append(newFriend)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
NSNotificationCenter.defaultCenter().postNotificationName("refreshTableView", object: nil)
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,6 @@ class FriendRequestViewController: UIViewController{
|
||||
@IBAction func sendButtonClicked(sender: AnyObject){
|
||||
var query = PFQuery(className: "_User")
|
||||
query.whereKey("username", equalTo: foundName.text!)
|
||||
println(foundName.text!)
|
||||
dispatch_async(dispatch_get_main_queue(),{
|
||||
query.getFirstObjectInBackgroundWithBlock({
|
||||
(object:PFObject?, error: NSError?) -> Void in
|
||||
|
||||
@ -108,12 +108,18 @@
|
||||
<state key="normal" image="Accept.png">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="didAcceptFriend:" destination="Rnb-lz-mp4" eventType="touchUpInside" id="Tdz-pW-bEv"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VKQ-62-km5">
|
||||
<rect key="frame" x="182" y="17" width="28" height="28"/>
|
||||
<state key="normal" image="Cancel.png">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="didRejectFriend:" destination="Rnb-lz-mp4" eventType="touchUpInside" id="cFh-Yk-AUE"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
|
||||
@ -13,6 +13,66 @@ class PendingRequestViewController: UITableViewController {
|
||||
|
||||
var requests = []
|
||||
|
||||
|
||||
@IBAction func didAcceptFriend(sender: AnyObject?){
|
||||
var path:NSIndexPath = self.table.indexPathForCell(sender?.superview!!.superview as! PendingFriendCell)!
|
||||
var cell: PendingFriendCell! = self.table.cellForRowAtIndexPath(path) as! PendingFriendCell
|
||||
|
||||
var query: PFQuery! = PFQuery(className: "FriendRequest")
|
||||
query.whereKey("username", equalTo: PFUser.currentUser()!.username!)
|
||||
query.whereKey("RequestStatus", equalTo: "pending")
|
||||
query.whereKey("inRealtionTo", equalTo: cell.friendName.text!)
|
||||
query.includeKey("OtherUser")
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), {
|
||||
query.getFirstObjectInBackgroundWithBlock({
|
||||
(object:PFObject?, error: NSError?) -> Void in
|
||||
|
||||
if(error == nil){
|
||||
object!.setObject("accepted", forKey: "RequestStatus")
|
||||
object!.save()
|
||||
PFUser.currentUser()?.relationForKey("FriendRequest").addObject(object!)
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), {() -> Void in
|
||||
PFUser.currentUser()!.saveInBackgroundWithBlock({
|
||||
(succeeded, error) -> Void in
|
||||
|
||||
if(succeeded){
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
//change requestStatus of other user who initiated request
|
||||
var otherQuery: PFQuery! = PFQuery(className: "FriendRequest")
|
||||
println(object!.objectForKey("OtherUser")!.objectForKey("username")!)
|
||||
otherQuery.whereKey("username", equalTo: object!.objectForKey("OtherUser")!.objectForKey("username")!)
|
||||
otherQuery.whereKey("inRealtionTo", equalTo: PFUser.currentUser()?.username as String!)
|
||||
otherQuery.whereKey("RequestStatus", equalTo: "Awaiting Response")
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), {
|
||||
otherQuery.getFirstObjectInBackgroundWithBlock({
|
||||
(object, error) -> Void in
|
||||
|
||||
if(error == nil){
|
||||
object!.setObject("accepted", forKey: "RequestStatus")
|
||||
object!.save()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
@IBAction func didRejectFriend(sender: AnyObject?){
|
||||
|
||||
}
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.title = "Friend Requests"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user