Closed liang162 closed 7 years ago
Good catch! The code you've implemented will give the correct results as well, but querying from the current user's perspective instead of the user
argument.
In the current tutorial, changing the code below should fix the bug:
Database.database().reference().child("followers").child(currentUID)
should be fixed to
Database.database().reference().child("followers").child(user.uid)
let ref = Database.database().reference().child(**"followers"**).child(currentUID)
should be:let ref = Database.database().reference().child(**"following"**).child(currentUID)
ref.queryEqual(toValue: nil, childKey: **currentUID**).observeSingleEvent(of: .value, with: { (snapshot) in
should be:ref.queryEqual(toValue: nil, childKey: **user.uid**).observeSingleEvent(of: .value, with: { (snapshot) in
The suggested solution will not give me the correct information about if a user is following another user. If I switch to another tab, and go back, it will not show "following" any more, even though the database shows the correct information.
I am not sure if this is something with the structure of my database, but the above changes fixed the problem.