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!