Conditional Logic to 'Thread' Multi-User Messaging Chain

Hi–looking for advice to make something more user friendly.

I’ve got a simple messaging system built that works fine and looks decent between two users. With two users, I can easily ‘thread’ the messages by aligning all of ‘my’ messages to the right-hand side of the repeating group…and aligning all of ‘your’ messages to the left-hand side (this works fine with group messages as well, as any message that is not ‘mine’ is handled the same–pushed to left-hand side).

Screenshot 2024-05-02 at 9.03.55 PM

Now, however, I’m building an Admin panel where all of the conversations (of messages) can be reviewed in one place for moderation. In this context, there is no ‘me.’ So what would be your recommendation on how to visually organize the messages of a given conversation?

The simplest would just be a chronological list, but that could be hard to follow as different users ‘speak.’

Ideally we could still have some sort of ‘thread’ setup where every time the message sender changes, the message flips from one side of the RG to the other (so for a conversation between 2 people, it would look the same as what I have now). But without a ‘current user’ being involved in the conversation, I’m struggling to figure out how to even do this, let alone extend the logic to several people (TBD, but maybe up to 5 or so in a conversation).

I’ve tried a few combinations of comparing current cell’s message owner to the previous (and/or next) cells message owner, but can’t figure out how to handle a ‘flip flop’ logic: if last message owner is different than this message owner, then align this message to the other side of the RG.

When there is more than 2, your aligning messages at either ends will not work anyways. So, I would suggest a standard approach to 2 users or 5 users. They all can be left aligned but the background colors might be different for example. One background color for each user? Something like this.

Thanks for your reply.

I’ve definitely considered this as well, but the issue is the conditional logic (regardless of what it controls), I think.

How would you recommend setting that up inside a repeating group when you aren’t sure how many users will be in a given conversation?

Or is there a way to somehow use custom states with background colors (or other styles)—not sure how you would iterate through the states/colors for each message.

Great question. Even this was not straight forward :slight_smile:
But you can define a maximum number of people to create some fixed colors (of this many) and use these colors for each person in the thread.

For example, I have created these fixed colors when the page is loaded:

I also save the people in the chat when the page is loaded (my case it is just the name of the people, you can get the unique users in your message):
image

And wherever I set the background, I just add conditionals. (Now this is the max number of users in a message thread. You can add more :slight_smile:) Your conditions will be checking the current message’s sender to the custom state’s index (1st, 2nd, 3rd etc) you gathered in previous step.

It will look like this for some messages and these senders:

You can check the example here: Tests for Forum 13 | Bubble Editor

@hergin thanks for this! Looks like it will work well for this use case, so I’ll play with it a bit and see.

Do you happen to know what the performance implications of several conditionals and/or several custom states are on the same element (or page)? If I replicate this (or similar multi-conditionals) in a few places on the same page (an Admin dashboard), will we start to see meaningful performance or workunit issues?

Thanks again for such a quick and thorough example.

1 Like

I guess you should test and see the performance :slight_smile:

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