Need Help With Chatroom App Structure

Hello! I am trying to build a chatroom app somewhat similar to Discord where users can create chatrooms, and within the chatrooms, they can create channels, and within those channels, they can send messages. I have run into two problems.

Problem #1:
I’ve been able to make a structure so that when a channel is chosen, the correct messages are pulled up. However, when changing chatrooms (I use a dropdown that pulls up every chatroom the user is in and auto-binds the change), the list of channel options changes accordingly but the messages don’t update until a new channel is chosen. As a result, the old messages from the previous channel stay until the user chooses a new channel from the new chatroom. For example, if I was one server A’s #general channel and change to server B, server B’s new channel options are updated but server A’s #general channel’s messages stay up until I pick one of server B’s new channels. Is there any way to implement the logic to make it so that when a user changes to server B, one of server B’s channels is chosen and updated in the messages automatically?

Problem #2:
In Discord, previous channel states seem to be saved for every server. For example, if I was previously on #general for server A, change to server B for a bit, and change back to server A, it will pull up #general and not other channels #announcements for example. I’d like for my app to be able to do this too but have no idea how this type of data would be stored and implemented.

At the moment, problem #1 is the more pressing concern, but any help with either would be greatly appreciated. Please let me know too if I need to elaborate or rephrase anything I said to be more clear. Thank you so much in advance!

Hey, so I completely over-engineered this when I first attempted it, but I’ve since gone on to create a fairly complex social media app and it’s pretty straight forward actually.

Problem #1

  1. Don’t try to manage everything with states - it’ll be unnecessarily complex
  2. Use the sudsy plugin and make every action change the URL (such as clicking a button or changing a dropdown), and then link your repeating group data source to the URL. There are free plugins that do something similar to sudsy, but in my experience they all drop the ball in some situations where Sudsy is super reliable.

i.e. Your base URL could be…

domain.com/page

When the user navigates to a specific chatroom you rewrite the URL to…

domain.com/page/chatroom

When they navigate to a specific channel it’ll become

domain.com/page/chatroom/channel

Then when you’re setting the datasource on the repeating group and you’re searching for messages you can pull in those URL paths dynamically into the search. So when the URL changes, then it’ll dynamically change the data source which will load the right messages.

The other major benefit of doing this is you can then reference the full URL elsewhere in the app or even in emails or whatever and the page will load exactly as you like if people navigate to it. If you use states then (ignoring #2) you end up putting everyone back to the start and then they need to click away to get to where they want to be.

Problem #2

This is pretty easy to do actually, you just need to store this data in the db so you can later refer to it.

Without knowing your DB structure, I’ll just assume the best place to put this would be in a field on the user table called something like “lastVisitiedChannel”.

If I’m using the sudsy plugin, I’d use a workflow that does x thing every time the URL changes. And then there’s one step in that workflow where you make changes to that field and store the current channel there. What this means is that each time the channel changes, then that field will be overwritten. A top tip is to ensure you deal with the alternate scenario where there is no specific channel and you’re at the chatroom level as a conditional

After that you can add a workflow to when the page loads for the first time to pick up that data and rewrite the URL as needed to then put them back to where they left off.

Anyway I’ve done all this and more in my app, so if you want me to walk you through that for inspo you can book 30 mins with me on my website and I’ll run you through it


Josh @ Support Dept
Helping no-code founders get unstuck fast :rocket:save hours, & ship faster with an expert :man_technologist: on-demand

Thank you so much! I’ll look into sudsy and try to get things going!

1 Like