return is remote participants is empty array

This commit is contained in:
Jessica Mitchell 2021-12-06 16:04:04 -05:00
parent f735bcf250
commit f8bd543a43
1 changed files with 3 additions and 0 deletions

View File

@ -72,6 +72,9 @@ export const useSharedState = ({ initialValues = {}, broadcast = true }) => {
new Date(p.joined_at) < new Date(localParticipant.joined_at)
);
// avoid sending message if no remote participants are available
if (remoteParticipants?.length === 0) return;
const randomPeer =
remoteParticipants[
Math.floor(Math.random() * remoteParticipants.length)