Spotz
Spotz

Reputation: 113

Android - How to see only friends' posts on firebase?

I am trying to build a semi social media app that has friends. On the friends page, I want the user to see posts only made by their friends.

I am using FirebaseRecyclerAdapter and query.

The friend data is saved like this:

Friends:
        userA:
              userB: true
              userC: true

How do I set the query so that userA is able to userB and Cs posts?

Upvotes: 0

Views: 411

Answers (1)

Alex Mamo
Alex Mamo

Reputation: 138969

To solve this, you need to query your database twice. First of all you need to query Friends -> userA to see which friends have the value set to true and then get them. Based on userB, userC you need to query again, to find actually the posts corecponding to this users. Assuming that your database looks like this Friends -> userB -> Posts> and Friends -> userC -> Posts>, you need to query only this posts.

Hope it helps.

Upvotes: 0

Related Questions