Extending the Travel Sample app

Hi, new here, trying to extend the functionality of the Travel app to get a better idea of how things work. So, im trying to add a favorite button that displays for every location/place in the list. The user is logged in and the expectation is that the heart icon displays for every place in the list, but when an item is favourited by the user it's a different icon.

Now im also new to Firestore... so my database is 3 tables one for users, one for places and one for favourites (called UserFaves) which has a ref to users and places

i've tried a backend query on the row (querying the UserFaves) that contains the icons but the row doens't display when the query returns nothing (when the user doesn't have a record in the UserFaves table). So it always either displays no icon (when there's no record) or, it displays the correct icon when there is a record/document. I can't seem to get the conditional logic down. I get that it's a condition case but i can't seem to work it out. Ive also tried setting a component state variable but it seems to be the same thing.

can someone point me in the right direction please?

1
2 replies