diff --git a/custom/shared/hooks/useSharedState.js b/custom/shared/hooks/useSharedState.js index a1ebce7..d4ada7a 100644 --- a/custom/shared/hooks/useSharedState.js +++ b/custom/shared/hooks/useSharedState.js @@ -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)