Forum Documentation Showcase Pricing Learn more

Keeping multiple messages in the same repeating group cell

#1

Hi,

Does anyone know how you’d go about keeping messages from the same user in the same repeating group cell?

This would be in a chat group, if a user sends multiple messages. See below, how would I go about keeping the name, avatar, and extra information just for the first message?

#2

I suggest checking out AirDev’s stretch-to-fit messenger. It’s a great example of how to set up a chat-type element in Bubble.

2 Likes
#3

Thanks Dan. Unfortunately, I know how to create the messenger, just stuck on how to keep the text from the same user in the same cell :frowning:

#4

@talbotnar Are you trying to have the repeating group cell say the User’s information only in the first Message cell? And then no information after that? So it would look like:

Jay Glase in Online Pay 15 minutes ago
“fef”
“wfe”

#5

Hi @fayewatson, correct. This happens sometimes on messaging apps when users press enter in between a couple messages.

#6

@talbotnar One option may be to put a transparent input into the repeating group cell. The initial content of that input would be “Current cell’s Index - 1” (to give us the previous cell index # of each repeating group cell).

Then, add this conditional statement to the elements you don’t want to show at all times (the name, avatar, extra information):

“When Repeating Group Messages: item# (Transparent Input’s Value)'s Creator is Current Cell’s Message’s Creator” --> This element is not visible.

This is telling Bubble, “if the Message before this Message was created by the same User, don’t show their information again”.

This way, the User information would only become visible if the previous Message was not sent by the same User. I haven’t tested but I think that might work :slight_smile:

#7

Hmm that definitely sounds like it should work!

I’m trying but can’t seem to figure out the correct expression:

There’s no option for creator after selecting the input’s value :frowning:

#8

Ah, sorry about that! :frowning: I just tried and couldn’t get the composer to accept “When Repeating Group Message’s List of Messages, item # (Transparent Input)'s value’s Creator is not Current Cell’s Message Creator” as well.

A different way would be to save this information in the database (this may not be ideal, if any other Bubblers have a different suggestion I’d be interested in hearing it as well!)

With the database approach, you could add a field to the Message type which is “Show User Info” (type: yes/no, list: no). Then, as new Messages are created, you would set that Message’s “Show User Info” field to “yes” when:
“Repeating Group Messages List of Messages: last item’s Creator is not Current User”
And set it to “no” when:
“Repeating Group Messages List of Messages: last item’s Creator is Current User”.

Note: The expression when you Create a New Message would just be:
Fields to Change
Show User Info = “Repeating Group Messages List of Messages: last item’s Creator is not Current User”. Then the value will be “yes” or “no” depending on if the expression is true or not for the new Message.

Once that’s set up, you can add two conditions to the User information elements in the repeating group cell:
"When Current Cell’s Message’s “Show User Info” is “yes” --> This element is visible.
"When Current Cell’s Message’s “Show User Info” is “no” --> This element is not visible.
*This would only affect New Messages created after you set up the fields and workflows.

One potential issue with this approach is if you allow Users to delete Messages. For example, if a User sent three Messages, and the first Message was deleted (which had the “Show User Info” field set to “yes”), then the second Message’s “Show User Info” field would need to be changed from “no” to “yes” in the delete workflow, to ensure the User’s info is shown for the new ‘first’ Message.

#9

Would you happen to know how to do last item - 1? Because since the message is already created, last item would be the one that was just created

#10

This should definitely work though

#11

I think it would be easier to set the value of the “Show User Info” field in the action that creates the new Message. So it would be:

That expression will give you the last Message sent before the new Message is created :slight_smile:

#12

Ah thank you! That works!!

I’m gonna try playing around with this, but it seems like erasing the space in between isn’t feasible.

Thank you so much though, I really appreciate the help

#13

Awesome! No problem at all! :smiley:

And right, it is tricky to get the spacing to collapse as expected! Here is an example:

Preview:

Editor:

#14

Ah I see now. Collapsing the group height, smart!

Only thing is, the message gets sent twice :o

#15

@talbotnar It looks like the group which contains the Message only is in its own repeating group? I’d double-check to make sure it’s only within a group element :slight_smile:

#16

Correct, I think it’s a workflow thing. Because when hitting enter for the second message, it’ll create a new message in the workflow, and give it it’s own repeating cell.

So the text will just be repeated

#17

Each Message will be in a cell no matter what, so a repeating group within the repeating group is not needed, and that is causing it to look like there’s a duplicate. If you use the same setup as the example (two regular groups within the cell, with conditional statements on each), it will work as expected :slight_smile:

#18

Sorry, what I meant was that it was a regular group, not a repeating group :o

#19

Ohh, no worries! :slight_smile: Can you share a link to the app editor (Temporarily set to public by going to Settings --> General --> Application Rights --> Everyone Can View or Edit? Or some screenshots of your setup and the workflows?

#20

Here is my solution:
ShowInfo