Skip to content

Commit

Permalink
fix: Makes the current user always appear in the first position of th…
Browse files Browse the repository at this point in the history
…e userlist (bigbluebutton#22235)

* restore current user always on top of userlist

always display current user on top of userlist

* fix ts error

* only include current user on first page

* fix current user data not updating

* change user injection method
  • Loading branch information
ramonlsouza authored Feb 19, 2025
1 parent 8510023 commit 544d4dd
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,24 @@ const UserListParticipantsPageContainer: React.FC<UserListParticipantsContainerP
const users = usersData ?? [];

const { data: currentUser, loading: currentUserLoading } = useCurrentUser((c: Partial<User>) => ({
isModerator: c.isModerator,
userId: c.userId,
voice: c.voice,
isModerator: c.isModerator,
presenter: c.presenter,
guest: c.guest,
mobile: c.mobile,
locked: c.locked,
userLockSettings: c.userLockSettings,
lastBreakoutRoom: c.lastBreakoutRoom,
cameras: c.cameras,
pinned: c.pinned,
raiseHand: c.raiseHand,
away: c.away,
reactionEmoji: c.reactionEmoji,
avatar: c.avatar,
isDialIn: c.isDialIn,
name: c.name,
color: c.color,
}));

const {
Expand Down Expand Up @@ -142,6 +156,16 @@ const UserListParticipantsPageContainer: React.FC<UserListParticipantsContainerP
));
}

const currentUserIndex = users.findIndex((u: User) => u.userId === currentUser?.userId);

if (currentUserIndex !== -1) {
users.splice(currentUserIndex, 1);
}

if (offset === 0) {
users.unshift(currentUser as User);
}

return (
<UsersListParticipantsPage
users={users ?? []}
Expand Down

0 comments on commit 544d4dd

Please sign in to comment.