(solved) Creating a like button, just like below this post

Hi again folks,

On my users posts I am trying to create the same like button as we have below this post. If 10 people like then the number shows ten likes and the love icon remains red. Even when the next time user logs in.

Trying to think multiple ways on how to set the data structure. I was thinking of adding a field type ‘likes’ in Users and setting that as yes/no. Then on the love icon, I could put a condition saying, if the current user’s like is yes, change the color to red.

Then I a lost on the number count part.

Please could someone help me think straight lol

Many thanks folks

Cheers

13 Likes

Are you just having “likes” or are you doing up/down voting ? Assuming the former …

On your post you want two fields …

And on the User you have …

So when you click like and the user doesn’t already have this thing in their like list …

Update the thing.

Update the user.

Have a conditional on the like button that changes it when the post is on the user;s like list.

You will need to think about handling what you want to do when someone “unclicks” like. Basically you want to -1 on the like count, and remove the user from the post, and the post from the user. So reverse the process.

7 Likes

Thanks Nigel. I will give it a shot and get back.

No luck Nigel. Would you mind, if you can recreate this on the forum app. I think I am messing up the data structure. I don’t get current cell location things in my settings.

Many thanks for your kind help Nigel.

Cheers

Ok, I re-read your instruction again and created as you advised. Now my issue is. I cannot see the elements in the preview. Just see a blank repeating group.

Find that strange. I thought something wrong with my app, then I created a fresh app and still the same.

Without data, there is nothing to display. So you won’t see your group.

Anyway, I added some data. You had set it up just fine :slight_smile:

We have two workflows, one when you already like something … another when you don’t.

They just do the opposite of each other.

I will pop this into Buildingonbubble when I get a chance.

3 Likes

Awesome Nigel. I will leave this public app on. The forum app was very slow on my end. Every click was a pain. Many thanks once again.

1 Like

Do you guys see any reason why this approach shouldn’t work with a single page application?

1 Like

@NigelG I was wondering what the “location” data type is for this. I was trying to build a similar feature for posts on an app like instagram, but I didn’t see where the location data type fits in.

1 Like

Hi there. It was just my listing data on the site (lists of locations) nothing special.

ok thanks!

1 Like

Hi @NigelG or @hdavy2002 , do issues arise when more than one user hits “like” on a thing at the same time or while the workflow is still running? or is it not that big of a deal?

Not an issue.

1 Like

hey, can you give me screen short in little more details . Thank you