Prevent Duplicate User Favorite Records with Firebase integration

I have a page in my app where a user can favorite something by clicking a heart. The integration works and when a user clicks the heart a record is created. The heart is meant to change colors after a record is created, however this doesn’t happen unless they leave the page and return. First question is how to make this happen right after the click? Second, related part here is that if the user doesn’t leave the page and keeps clicking the heart, duplicate records are created in the database. If they leave the page and come back the record gets deleted though. The second question is how allow a user to delete a record with the second click of the heart. I’ve included a picture of the component tap logic flow below. The IF utility statement is:

IS_EMPTY(data[“User Favorites1”][0])

Any ideas on what I am missing?