Skip to content

Commit

Permalink
feat(frontend): no show current user in users list
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlyJazz committed Dec 10, 2023
1 parent b9fe6fa commit a1aa5f8
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions frontend-web/src/app/chat/[[...id]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,35 +128,37 @@ const ChatPage = () => {
}}
>
{!usersError &&
usersData.map((user) => {
const friendOrUnknow = chatsData?.some((chat) =>
chat.users_id.includes(String(user.id))
);
return (
<Menu.Item
key={user.id}
onClick={() => handleUserSelect(user)}
>
<Space>
<Badge
size="small"
count={friendOrUnknow ? "" : "?"}
color={friendOrUnknow ? "green" : "yellow"}
>
<Avatar
size={"small"}
style={{
backgroundColor: stc(user.username + user.id),
}}
usersData
.filter((n) => String(n.id) !== String(currentUserId))
.map((user) => {
const friendOrUnknow = chatsData?.some((chat) =>
chat.users_id.includes(String(user.id))
);
return (
<Menu.Item
key={user.id}
onClick={() => handleUserSelect(user)}
>
<Space>
<Badge
size="small"
count={friendOrUnknow ? "" : "?"}
color={friendOrUnknow ? "green" : "yellow"}
>
{user.username[0]}
</Avatar>
</Badge>
<Typography.Text>{user.username}</Typography.Text>
</Space>
</Menu.Item>
);
})}
<Avatar
size={"small"}
style={{
backgroundColor: stc(user.username + user.id),
}}
>
{user.username[0]}
</Avatar>
</Badge>
<Typography.Text>{user.username}</Typography.Text>
</Space>
</Menu.Item>
);
})}
{usersError ? (
<Space>
{/* Display error message */}
Expand Down

0 comments on commit a1aa5f8

Please sign in to comment.