Add ability to toggle presenter by clicking name
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user