How to sort a repeating group

Hi, I have a list of notifications. A user receives a notification, when somebody commented his post. When he clicks on “Zum Post” he gets to the screen which contains the current post with this comment. (picture 1)

Know I want to sort the repeating group of comments (picture 2) so that this specific comment, on which the user clicked “Zum Post” is at the top. When another user comments this post and the creator of the post clicks on “Zum Post” again, there should be this comment on the top.

Does somebody know how to do that?

Best wishes
Jakob

Picture 1:

Picture 2:

You can add one more field in your DB and use this field for sorting and manipulating as you want.

1 Like

This isn’t really sorting, it’s more like “injecting a Comment in front of a list of Comments”

@Jakob1 when they tap on the notification, is it another page it goes to, or just hides/shows groups?

You can have a custom state with the type Comment. Then your repeating group source is [your custom state]: converted to a list merged with [your current data source]

So it always puts the custom states value 1st. Then you just need to fill in that custom state with the relevant comment.

If it’s on the same page you can just use the “Set state of an element” or if it’s another page you can send the comment as a URL parameter, then on the Comments page you set the state on page load to that parameters’s Comment

1 Like

Ok thanks I’ll try it :smiley:
And when you tap on the notification you get to another page

Should I have the custom state on the notification page, or on the comment page?

You know what, just add the URL parameter’s comment directly instead of the custom state and see what happens.
This would be your navigate workflow from the Notifications page:

Then your data source for your comments:

“sc” for Selected comment, but you can name this whatever you want as long as it’s the same in your page action and the source. User’s will see it in the browser URL bar.

The actual thing to type is “Get data from page URL” but Bubble renames it once you type the parameter name like in my screenshot.

1 Like

Thank you very much :smiley:

Do you know why I only have the option to convert to number und not to list?

Oh, I found the issue, the type was text and not comment.

But when I click on a comment on the notification screen and get to the comment screen, the current comment is still not on the top.

I added another key (now it is the story of the comment and the comment) and it works properly. Thank you very much :smiley:

1 Like

Do you maybe know if it is possible to color this comment. So the cell of the comment of the notification should have another background than the other comments.

I managed to do it in this way :smiley:

image

Yep was just about to send a screenshot like that. :+1:

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.