Add ability to toggle presenter by clicking name

This commit is contained in:
Robert Long
2021-08-26 11:03:48 -07:00
parent a4e8949907
commit 1661c5518b
5 changed files with 354 additions and 70 deletions

View File

@@ -20,6 +20,19 @@ export function GridDemo() {
]);
}, [stream]);
const togglePresenter = useCallback((selectedParticipant) => {
setParticipants((participants) =>
participants.map((participant) =>
participant === selectedParticipant
? {
...participant,
presenter: !participant.presenter,
}
: participant
)
);
}, []);
const removeParticipant = useCallback((key) => {
setParticipants((participants) =>
participants.filter((participant) => participant.userId !== key)
@@ -43,7 +56,7 @@ export function GridDemo() {
</button>
)}
</div>
<VideoGrid participants={participants} />
<VideoGrid participants={participants} onClickNameTag={togglePresenter} />
</div>
);
}