Conditions for when a user clicks something

Hey guys! :wave:

I recently built a social media app for sharing audio. Everything is (almost) set up except for the likes, dislikes, and followers option. I set up the likes, so when the user clicks the thumbs up button, the like count adds one. Easy-peasy. Just like the dislikes and followers.

Here is where the problem starts.

A user clicks the like/dislike/follow button. The like count adds one. The user clicks it again. It adds another one. :expressionless: Is there some way to make it so that when the user clicks it, it adds one, but when that user clicks it again, it subtracts one?

Thanks, Pablo

I doubt what you’re asking for is possible right now with Adalo, so now you need to look for a workaround to the problem.

You probably need to move away from a +1 counter to making a collection (table) of votes and record the user ID with the vote. That might get you closer, but I don’t think there’s a “if unique” type filter option in Adalo yet either.

So maybe you need to get creative from there still… Perhaps record a datetime of when the votes happened, and only count where user ID = x and date = most recent, something like that.

I wonder also if the visibility settings might allow you to disappear or replace the like button by using a greater than filter somehow.

Maybe you’d need to use the blank screen trick for that, so you do the like, then send to a blank screen where it updates a field, say “Voted = true”, then returns them to the previous screen but now the visibility settings can see the field you updated and see they’ve already voted, so it won’t display the like button or it will display it differently (greyed out, unlinked, etc)

I think I’d start with the visibility settings and blank page trick first if I was you, seems like it gets you closest.

Blank page trick in action:

Maybe someone better at this than I am knows of a more elegant solution to this simple problem.

1 Like

Hi @Pablo_books, @parasocks,

To my mind, may be you’re overcomplicating things here? :slight_smile:

See tutorial here:
and here:

For the “Favorite” button, the thing which is not very clear in a tutorial, is that you need to create a “many-to-many” relationship between User and Destination. And then with the help of Toggle component, this relationship could be set and un-set.

You will get the total count of likes by Current Destination -> User relationship -> Count.

Replace “Favorites” with “Likes” and you will get the Likes system. If you would like to have “Dislikes”, you can just replicate the same logic.

I can do the video, but I think it’s already covered somewhere :slight_smile:


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.