Follow and unfollow system

Hello guyz

I was trying to enable a follow and unfollow system in my app. What I did is that I created to seprate buttons for following and unfollowing. The data type contain the field of users
Followers - list of users

My logic of working this functionality is that

  1. follow button is visible only when the current page user follower’s doesn’t contain current user

And also I added when follow button is clicked following button (unfollow) is shown.

Similarly i did the reverse to following button( unfollow) to unfollow the user. So when the button is clicked follow button is shown

The problem is while I refresh it always shows the following button (unfollow). It doesn’t showing the follow button. Can someone help me to solve this problem.

Here I am attaching some snaps of my workflow for the follow button