Merge pull request #51 from daily-demos/dev-1107-useSharedState-add-early-return
Add early return in case remote participant array is empty (useSharedState)
This commit is contained in:
commit
17e022dbc2
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue