fix setting setSubscribedTracks when null
This commit is contained in:
parent
c31b19a797
commit
6e25f32f4b
|
|
@ -123,6 +123,25 @@ export const ParticipantsProvider = ({ children }) => {
|
|||
*/
|
||||
const username = callObject?.participants()?.local?.user_name ?? '';
|
||||
|
||||
const [muteNewParticipants, setMuteNewParticipants] = useState(false);
|
||||
|
||||
const muteAll = useCallback(
|
||||
(muteFutureParticipants = false) => {
|
||||
if (!localParticipant.isOwner) return;
|
||||
setMuteNewParticipants(muteFutureParticipants);
|
||||
const unmutedParticipants = participants.filter(
|
||||
(p) => !p.isLocal && !p.isMicMuted
|
||||
);
|
||||
if (!unmutedParticipants.length) return;
|
||||
const result = unmutedParticipants.reduce(
|
||||
(o, p) => ({ ...o[p.id], setAudio: false }),
|
||||
{}
|
||||
);
|
||||
callObject.updateParticipants(result);
|
||||
},
|
||||
[callObject, localParticipant, participants]
|
||||
);
|
||||
|
||||
/**
|
||||
* Sets the local participant's name in daily-js
|
||||
* @param name The new username
|
||||
|
|
@ -227,6 +246,8 @@ export const ParticipantsProvider = ({ children }) => {
|
|||
participantMarkedForRemoval,
|
||||
participants,
|
||||
screens,
|
||||
muteNewParticipants,
|
||||
muteAll,
|
||||
setParticipantMarkedForRemoval,
|
||||
setUsername,
|
||||
swapParticipantPosition,
|
||||
|
|
|
|||
|
|
@ -238,7 +238,10 @@ export const TracksProvider = ({ children }) => {
|
|||
}
|
||||
|
||||
if (rtcpeers?.getCurrentType?.() === 'peer-to-peer') {
|
||||
result.setSubscribedTracks.video = true;
|
||||
result.setSubscribedTracks = {
|
||||
...result.setSubscribedTracks,
|
||||
video: true,
|
||||
};
|
||||
}
|
||||
return { [id]: result };
|
||||
}, {});
|
||||
|
|
|
|||
Loading…
Reference in New Issue