Allow users to Like Chat messages

I’ve been enhancing the chat component in my Glide Apps by adding a feature to ‘like’ chat messages, a new concept for chat comments. Users can like a message by holding it down to activate a menu with a ‘like’ option. This triggers a slide-in window, showing the message and a ‘Like’ button. When clicked, the user’s name is added to a list of those who liked the message. An identical button is then displayed with a ‘remove user name from list’ to manage the like/unlike functionality.

Furthermore, I’ve used a template column to concatenate the heart icon and the number of likes with the original author’s name. This allows the chat list to display the number of likes each message has received. This method offers a straightforward way to incorporate a liking feature into any chat element within an app.

5 Likes

Thanks for the explanation!

How did you set up the list of users that have liked the comment, and what action do you use to add the user name to the list?

Hi there… hopefully this explains the actions used to add the user name to the list.

Simon.

Sorry, didn’t explain very well in the video… obviously, the Replace columns are taking the master list of names and then replacing ‘user name’ with nothing. Importantly, ‘user name’ can be 'user name, ’ or ‘, user name’. This deletes both ways in which the user name might appear in the list depending on whether they appear first in the list or not.

1 Like

This is awesome, thanks so much for the great video and explanation! I’m going to borrow your reply setup as well!

After watching the video several times, I’m still not sure how a name gets added to the Master List Who Likes. What action is performed so that a name is added to that list? Sorry if you already explained it and I didn’t pick up on it. Thanks!

When the user taps the Like button, the App runs an action that Sets column. This means the Master List column is updated by setting it with the contents of a column that has the current list plus the user name. In reality, that column is smart and uses and If/then/else to decide whether to add only the user name (first like) or ‘list, user name’. Notice the comma.

If the master list already contains the name of the user then a different button is displayed. Now when the user taps Like the action will result in the user name being removed from the master list. Once again, an action ‘set column’ is used. However, this time the master list is updated with a new list in which the name of the current user is deleted. This is why there are ‘Replace all’ columns. They replace all instances of the user name in the master list with blank, effectively removing the name. Once again, a couple of columns are needed depending on whether the list contains only the user (only the user has liked) or if it contains a ‘list of names including the user’.

Hope this helps…

1 Like

@Robert_Petitto maybe you could work your magic and make a short video on how to use what is effectively the Trebuchet method to handle the likes list in a Chat component.

The more I try to explain things with several steps like this the more I respect your videos!

1 Like

Thanks Simon, I think I see what you mean here. The action is using the If/Then/Else to overwrite what is already in the Master Like List. And the If/Then/Else is just picking the template based off of if there are already names in the Master Like List or not. Took me a minute to wrap my hear around the concept. Thanks!

1 Like

Correct.

1 Like

If you make the video that Simon suggested, perhaps also cover the option of using a Multiple Files/Images column with arrays in preference to Joined Lists? (which I believe is a more elegant and simpler solution).

2 Likes