fix setting setSubscribedTracks when null

This commit is contained in:
Jon 2021-07-12 17:12:08 +01:00
parent c31b19a797
commit 6e25f32f4b
2 changed files with 25 additions and 1 deletions

View File

@ -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,

View File

@ -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 };
}, {});