Guest User

Untitled

a guest
Jul 16th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. 0x0000000102bb3fe8 vipeeps`partial apply forwarder for closure #1 (Swift.Array<Any>, Swift.Bool) -> () in vipeeps.ConversationsListVC.loadNewInvitesData() -> () at ConversationsListVC.swift
  2.  
  3. func getComplimentsReceived(forUserId forId: String, handler: @escaping (_ complimentPack: [Any] ,_ success: Bool) -> ()){
  4.  
  5. var compliments = [Any]()//empty array to hold compliments
  6.  
  7. REF_USERS_COMPLIMENTS.child(forId).observe(.value) { (snapshot) in
  8.  
  9.  
  10. for item in snapshot.children{
  11.  
  12. let itemSnap = item as! DataSnapshot
  13.  
  14. let dict = itemSnap.value as! [String : Bool]
  15.  
  16.  
  17. for (key, status) in dict {
  18.  
  19. switch status {
  20.  
  21. case true:
  22.  
  23. self.REF_USERS.child(snapshot.key).observeSingleEvent(of: .value, with: { (snapshot) in
  24.  
  25. let uid = snapshot.key
  26. let name = snapshot.childSnapshot(forPath: "name").value as! String
  27. let email = snapshot.childSnapshot(forPath: "email").value as! String
  28. let profilePictureURL = snapshot.childSnapshot(forPath: "profilePictureURL").value as! String
  29.  
  30. let birthday = snapshot.childSnapshot(forPath: "birthday").value as! String
  31. let firstName = snapshot.childSnapshot(forPath: "firstName").value as! String
  32. let lastName = snapshot.childSnapshot(forPath: "lastName").value as! String
  33. let gender = snapshot.childSnapshot(forPath: "gender").value as! String
  34. let discoverable = snapshot.childSnapshot(forPath: "discoverable").value as! Bool
  35. let online = snapshot.childSnapshot(forPath: "online").value as! Bool
  36.  
  37. let discoveryPrefs = snapshot.childSnapshot(forPath: "discoveryPrefs").value as! [String : Any]
  38.  
  39. let dictionary: [String : Any] = ["uid": uid, "name": name, "email": email, "profilePictureURL": profilePictureURL, "birthday": birthday, "firstName": firstName, "lastName": lastName, "gender": gender, "discoverable": discoverable, "online": online, "discoveryPrefs": discoveryPrefs]
  40.  
  41. let user = User(uid: uid, dictionary: dictionary)
  42.  
  43. let complimentPack = [
  44. "type": "compliment",
  45. "complimentId": key,
  46. "active": status,
  47. "fromUser": user
  48. ] as [String : Any]
  49.  
  50. compliments.append(complimentPack)
  51.  
  52. print("compliments.count: (compliments.count)")
  53.  
  54.  
  55. })//end observer
  56.  
  57. case false:
  58. print(status)
  59.  
  60. break
  61.  
  62. }//end switch
  63.  
  64. }//end for dict
  65.  
  66. handler(compliments, true)
  67.  
  68. }//end for snapshot.item
  69.  
  70. }//end observe
  71.  
  72. }//end func
Add Comment
Please, Sign In to add comment