Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Breakout Rooms] Improve split users functionality #236

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,21 @@ export const BreakoutManager: React.FC = () => {

const handleSplitUsers = async () => {
const count = rooms.length;

// This needs to be only new users
const users = unassignedUsers;
const roomSize = Math.max(Math.floor(users.length / count), 1);

const roomSize = Math.max(Math.ceil(users.length / count), 1);
const usersInRooms: OnlineUserInfo[][] = [];

for (let i = 0; i < users.length; i += roomSize) {
usersInRooms.push(users.slice(i, i + roomSize));
}

// Sort rooms by number of participants in ascending order
const sortedRooms = [...rooms].sort((a, b) => a.participants.length - b.participants.length);

for (let i = 0; i < count; ++i) {
const room = rooms[i];
const room = sortedRooms[i];
const participants = usersInRooms[i];
for (const participant of participants) {
await service.addParticipant(room, participant);
Expand Down
Loading