Skip to content

Commit

Permalink
refresh friends upon add + delete
Browse files Browse the repository at this point in the history
  • Loading branch information
ewang001 committed Dec 8, 2023
1 parent 7a2be93 commit c0c9572
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/newHere1/newHere/Views/FriendsView/Friends.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ struct Friends: View {
self.errorMessage = error.localizedDescription
}
}
// Update friends after adding
getAllUserFriends(userId: userId) { result in
switch result {
case .success(let response):
print("Friends fetched successfully: \(response)")
self.friendsList = response.values.map { $0 }

case .failure(let error):
print("Error getting friends: \(error.localizedDescription)")
self.errorMessage = error.localizedDescription
}
}

}) {
Text("Add Friend")
Expand Down Expand Up @@ -130,6 +142,18 @@ struct Friends: View {
self.errorMessage = error.localizedDescription
}
}
// Update friends after adding
getAllUserFriends(userId: userId) { result in
switch result {
case .success(let response):
print("Friends fetched successfully: \(response)")
self.friendsList = response.values.map { $0 }

case .failure(let error):
print("Error getting friends: \(error.localizedDescription)")
self.errorMessage = error.localizedDescription
}
}
}){
Image(systemName: "minus.circle")
.font(.system(size: 28))
Expand Down

0 comments on commit c0c9572

Please sign in to comment.