The problem is this, I need to display a list of users in a modal window, but the problem is that the list of all names is constantly duplicated there, how can this be avoided? And to be equally visible to all users on the page Here is the code how it works:
const addUserToModalWindow = () => {
const contentWindow = document.querySelector(".usersList");
socket.on('users', (users) => {
for (let user of Object.values(users)) {
contentWindow.innerHTML += `<div>• ${user.name}</div>`;
}
});
};
Here are the photos of what is duplicated (there is no duplication on the second page, if you open the third, then duplication will be on the second and so on)
