process user as object

This commit is contained in:
2025-08-16 23:30:49 +02:00
parent 5de174b162
commit 698c41544c
+9 -10
View File
@@ -73,19 +73,18 @@ export default function Lobby() {
getTrack(); getTrack();
} }
function addUser(userName: string) { function addUser(user: object) {
console.log(userList); console.log(userList);
if (userList.find((user) => user.name == userName)) { // if (userList.find((u) => u.name == user?.["username"])) {
return; // return;
} // }
const newUser = { const newUser = {
id: userName, id: user["id"],
name: userName, name: user["username"],
avatar: `https://i.pravatar.cc/150?img=${userList.length + 1}`, avatar: `https://i.pravatar.cc/150?img=${user["id"]}`,
host: userList.length === 0,
}; };
const newUserList = [...userList, newUser];
setUserList(newUserList); setUserList([...userList, newUser]);
} }
async function getTrack() { async function getTrack() {