fixes userlist
This commit is contained in:
@@ -74,17 +74,19 @@ export default function Lobby() {
|
||||
}
|
||||
|
||||
function addUser(user: object) {
|
||||
console.log(userList);
|
||||
// if (userList.find((u) => u.name == user?.["username"])) {
|
||||
// return;
|
||||
// }
|
||||
const newUser = {
|
||||
id: user["id"],
|
||||
name: user["username"],
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user