fixes userlist

This commit is contained in:
2025-08-17 10:05:51 +02:00
parent 698c41544c
commit 7d54f6c5ce
+7 -5
View File
@@ -74,17 +74,19 @@ export default function Lobby() {
} }
function addUser(user: object) { function addUser(user: object) {
console.log(userList);
// if (userList.find((u) => u.name == user?.["username"])) {
// return;
// }
const newUser = { const newUser = {
id: user["id"], id: user["id"],
name: user["username"], name: user["username"],
avatar: `https://i.pravatar.cc/150?img=${user["id"]}`, avatar: `https://i.pravatar.cc/150?img=${user["id"]}`,
}; };
setUserList([...userList, newUser]); setUserList((prevUserList) => {
if (prevUserList.find((u) => u.id === user["id"])) {
console.log("User already exists, not adding");
return prevUserList;
}
return [...prevUserList, newUser];
});
} }
async function getTrack() { async function getTrack() {