How can I solve these problems of in medical chat app?

The first problem is that when registering, it is possible to send between two people, but if someone else logs in then he sees all the messages, how do I separate the messages so that each user has his own chat page
The second problem is , there is a chat between a patient and a doctor, so when he enters the application, a list of doctors who have registered in this application appears for him in order to choose from among them who will chat with him
Is there any way to solve these two problems? :worried:

Are you using CloudDB for the chat?

yes , and I use Firebase for log in form and sign up

See this topic

Also you can search in the forum for existing topics

:mag: CloudDB Chat

I want every user side to side chat which is private so if any user sign up and select the same doctor chat screen appear form him and didn't see other message.

Once the user log in we can display a list of doctors using ListViewer/Spinner and then join the name of user and doctor.
example: If user is ElonMusk1 and doctor is DrAli then the chat data is stored in a tag "ElonMusk1DrAli "

and set the chat to the tag " ElonMusk1DrAli ". this way it can be accessed easily and remained saved even if user logs out. Also the chat will only be visible to the two persons only.

can you show blocks if write it ? may can edit it but using firebase to see how I can write it