Now we need to maintain some kind of data structure for all of the conversations that we have inside
of the app, so inside of the producer, let's make a initial property here inside the state.
That's called conversations, which is going to be an object.
And then under the users online, we are going to add new conversations with the user IDs as the users
are coming online.
So first, let's make the conversations, shall copy here from the state by using the spread operator.
State the conversations.
And then let's take the users online and put that in a variable for itself from the action data.
Then let's go for a for loop of each of the losers that is online.
He says online.
And.
Then it's declared to use I.D. here and available users online.
User I.D. and here we need to check if this user IDs over the already existing inside of our conversations.
So if conversations user I.D..
It's undefined, they will create a new object, so conversations, user I.D. and help create a new
object.
Now with these messages, a rate that's being initialized as an empty array and then a user name, the
user name is more for our own sake so that we can easily see which conversation is to who.
So that's more for debugging purposes, then we have the user a name, and then let's update this state
with these new properties so we can then just say users online and then CUMA conversations.
Now, let's take a look inside of the console lock as we join the chat and see how it looks.
OK, now let's take a look inside the council and here we can see a new state with a conversation about
property with all of the different user IDs we have here.
And then they each have a mistress array and then also use a name just for our own debugging purposes.
OK, so all of this could now.