good spot, but still not seamless...work slowly towards it

This commit is contained in:
talksik
2021-12-21 04:15:38 -08:00
parent 799a3c82f4
commit 668d8563f4
+14 -8
View File
@@ -221,6 +221,9 @@ extension AuthSessionStore {
return return
} }
// resetting array to reset friends
self.friendsArr = []
for document in querySnapshot!.documents { for document in querySnapshot!.documents {
let userFriend:UserFriends? = try? document.data(as: UserFriends.self) let userFriend:UserFriends? = try? document.data(as: UserFriends.self)
@@ -228,16 +231,18 @@ extension AuthSessionStore {
self.db.collection("users").document(userFriend!.friendId).getDocument { (document, error) in self.db.collection("users").document(userFriend!.friendId).getDocument { (document, error) in
if let document = document, document.exists { if let document = document, document.exists {
let returnedUser = try? document.data(as: User.self) let returnedUser = try? document.data(as: User.self)
if returnedUser != nil { DispatchQueue.main.async {
self.friendsArr.append(returnedUser!) if returnedUser != nil {
self.friendsArr.append(returnedUser!)
// if this friend do not exist in the dict, add it to show up in my circle // if this friend do not exist in the dict, add it to show up in my circle
// TODO: prolly don't need this function to mess with dictionary // TODO: prolly don't need this function to mess with dictionary
if self.friendMessagesDict[returnedUser!.id!] == nil { if self.friendMessagesDict[returnedUser!.id!] == nil {
self.friendMessagesDict[returnedUser!.id!] = [] self.friendMessagesDict[returnedUser!.id!] = []
}
print("added this user to the array of users for user's circle\(returnedUser)")
} }
print("added this user to the array of users for user's circle")
} }
} else { } else {
print("user doesn't exist from user friend relationship") print("user doesn't exist from user friend relationship")
@@ -246,6 +251,7 @@ extension AuthSessionStore {
} }
} }
// TODO: optimize later with the conditionals // TODO: optimize later with the conditionals
// guard let snapshot = querySnapshot else { // guard let snapshot = querySnapshot else {
// print("Error fetching user's friends: \(error!)") // print("Error fetching user's friends: \(error!)")