Skip to content
Snippets Groups Projects
Unverified Commit adbb23a7 authored by Samuel Couillard's avatar Samuel Couillard Committed by GitHub
Browse files

fix(room join): room join waiting queue improvement (#5072)

* Rebase

* Waiting queue improvement

* Change mp3

* Reduce step time

* Remove audio from assets path config

* Fix typos

* Improve comments

* Put delay on toast and sound

* Add mp3 loader to esbuild prod configs

* Serve mp3 from public assets

* Add relative url
parent 076f0bdb
No related branches found
No related tags found
No related merge requests found
...@@ -100,15 +100,43 @@ export default function RoomJoin() { ...@@ -100,15 +100,43 @@ export default function RoomJoin() {
} }
}, [roomStatusAPI.isSuccess]); }, [roomStatusAPI.isSuccess]);
// Play a sound and displays a toast when the meeting starts if the user was in a waiting queue
const notifyMeetingStarted = () => {
const audio = new Audio(`${process.env.RELATIVE_URL_ROOT}/audios/notify.mp3`);
audio.play()
.catch((err) => {
console.error(err);
});
toast.success(t('toast.success.room.meeting_started'));
};
// Returns a random delay between 2 and 5 seconds, in increments of 250 ms
// The delay is to let the BBB server settle before attempting to join the meeting
// The randomness is to prevent multiple users from joining the meeting at the same time
const joinDelay = () => {
const min = 4000;
const max = 7000;
const step = 250;
// Calculate the number of possible steps within the given range
const numSteps = (max - min) / step;
// Generate a random integer from 0 to numSteps (inclusive)
const randomStep = Math.floor(Math.random() * (numSteps + 1));
// Calculate and return the random delay
return min + (randomStep * step);
};
useEffect(() => { useEffect(() => {
// Meeting started: // Meeting started:
// When meeting starts this logic will be fired, indicating the event to waiting users (through a toast) for UX matter. // When meeting starts this logic will be fired, indicating the event to waiting users (through a toast) for UX matter.
// Logging the event for debugging purposes and refetching the join logic with the user's given input (name & codes). // Logging the event for debugging purposes and refetching the join logic with the user's given input (name & codes).
// With a delay of 7s to give reasonable time for the meeting to fully start on the BBB server.
if (hasStarted) { if (hasStarted) {
toast.success(t('toast.success.room.meeting_started')); console.info(`Attempting to join the room(friendly_id): ${friendlyId} meeting.`);
console.info(`Attempting to join the room(friendly_id): ${friendlyId} meeting in 7s.`); const delay = joinDelay();
setTimeout(methods.handleSubmit(handleJoin), 7000); // TODO: Amir - Improve this race condition handling by the backend. setTimeout(notifyMeetingStarted, delay - 1000);
setTimeout(methods.handleSubmit(handleJoin), delay); // TODO: Amir - Improve this race condition handling by the backend.
reset();// Resetting the Join component. reset();// Resetting the Join component.
} }
}, [hasStarted]); }, [hasStarted]);
......
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment