Custom State for RG Question

Hello Bubblers,

I have a RG doing a search for members of two merged lists, both sorted by Follower count (number), with a follow button and workflow to + or - follower count. I’ve read that to achieve a RG to NOT bounce around like this is to set a custom state and then load that state on page load.

However, I’m not sure on which element to apply a custom state to and how it should be set up so that the order doesnt automatically update but only after a page refresh/load.

Hi there, @trvshowell… after messing around with this one for longer than I care to admit, I believe there is only one answer…

You need to get you some List Shifter. :slight_smile:

Truth be told, I try to do everything in Bubble without using plugins. After trying like hell to get a custom state solution to work (I’m sure I read the same posts you did about how a custom state is likely the way to go here), I realized (possibly incorrectly) that we can’t go that route because your situation is somewhat unique.

I’m assuming when the follow/unfollow button is clicked, you want the followers count to update, but you don’t want the repeating group to re-sort because that makes stuff bounce around. If that assumption is correct, a custom state solution won’t work (or, more accurately, I couldn’t get a custom state solution to work) because you can’t sort by something that is not in the database.

So, it sounds to me like you need a way for the list to keep its original sort order while the followers counts update in real time. Then, when the page is refreshed, the list re-sorts and displays the new order based on the updated counts. Sound about right? If so, enter List Shifter.

I have a working example (it doesn’t merge two searches, though) and can provide screenshots if you need them, but in a nutshell, you need to…

  • Add a List Shifter element to the page and set the list to shift to your searches but without the sorting.
  • Create an initialized/updated workflow event for your list shifter element (the beginning of this post by the plugin’s creator was super helpful in understanding why that event is critical)
  • Create a workflow action within the above event that sorts the list shifter element by a list of the original list’s (each item’s) followers, make the sort a number, and set descending to yes

At that point, you should have the desired behavior, assuming I have interpreted the desired behavior correctly. If I haven’t, then at the very least, I have popped your post to the top of the stack for a hot minute so someone can come along and tell/show me why I’m an idiot for not being able to get a custom state solution to work.

Hope this helps.

Best…
Mike

1 Like

Maybe I’m not understanding the whole situation here but I don’t see why this custom state wouldn’t work.

When a user clicks on Follow, my expectation is that it adds that designer to a list of people followed on the current user and also adds 1 to the designers follow count.

Your custom state is already ordered by the following count and will not change so the repeating group shouldn’t shift around?

1 Like

I’m sure you checked out the second link in the initial post, @juicebox, and I’ll be damned if I could get that behavior to stop by using a custom state. If you can, please share an example because I went deep on this one, but I couldn’t manage to get a custom state solution to work.

@mikeloc I think this is what you’re after?

Demo: https://static-repeating-group.bubbleapps.io/version-test?debug_mode=true
Editor: Static-repeating-group | Bubble Editor

3 Likes

Well, that definitely looks like something. :slight_smile:

I could certainly have been making this one a lot harder than it needs to be, and I will have to get my head back into the space of the initial post’s exact set up to see why I was complicating something that looks so easy now that I see your example. For some reason, I think the example is configured a bit differently, but I will have to dig deeper when it’s not 2:15am. Ug, I swear Bubble is going to be the death of me.

Thanks for taking the time to put an example together, @juicebox… very much appreciated!

1 Like

No worries @mikeloc - let me know if there is some additional complexity to take into account and you want me to take a look.

2 Likes

Well, it’s a much more reasonable hour now (6:37am… damn you, Bubble, let me sleep!), and I can’t figure out for the life of me how I got down the path on this one where I thought the only option was the plugin. Thanks again for the example, @juicebox… good stuff. @trvshowell, definitely check that example out because that’s the solution you want here. Don’t get me wrong, you can use List Shifter because, well, I did, but a simple custom state will do the trick quite nicely.

1 Like

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