Hi Bubble community,
I’m stuck on getting my like/dislike votes to properly render. The setup is as follows.
A thumb up and thumb down for voting exist in two places. There’s a reusable item card on a repeating group in a library, and then an item details page that also has a thumb up/down.
Using the thumb up as an example, my logic is:
- default thumb is empty
- when “voted” is no, fill the thumb up when the user’s likes contain this item. This does the initial population/display based on the database value
- when the thumb is tapped, “voted” is set to yes, a “liked” state (defaulted to no) is set to yes if the db value is liked, and the immediately the state is set to flip. This way when the item is liked in the db, the flip makes it no longer liked. But if it is not set to like in the db, then it now sets to like.
All of this is working in both places. The problem is that if a user taps a thumb in the library, “voted” is set to yes. It correctly displays either the filled or empty thumb, but then if they go to the details page and change their vote and go back to the library, it no longer displays correctly because the state is still set to “yes” so it’s displaying the last state that was set on the library. I thought that navigating to the details page would reset all the state values on the library, but apparently not so.
Curiously, I am not having this problem in the reverse.
Scenario A:
- user taps an icon on the recipe library (voted is set to yes)
- user navigates to the recipe details. display is correct (details page voted is still set to no)
- user taps icon in the recipe details (voted is set to yes)
- user navigates to the recipe library. Display is NOT correct
Scenario B:
- user taps an icon in the details page (voted is set to yes)
- user navigates to the library. display is correct (library page voted is still set to no)
- user taps an icon on the library (voted is set to yes)
- user navigates to the details play. Display IS correct
Since I can’t set states across pages, I can’t figure out how to get this working. I could just drive the visuals based on the db values, but I moved away from that because it was so slow. If I remove the “voted” condition, then the display flips when there’s a discrepancy between the state and the db value.
Any recommendations are appreciated.