Skip to content

Commit

Permalink
Merge pull request #261 from Azure-Samples/chwhilar/fix-app-pinLogic
Browse files Browse the repository at this point in the history
Fix app's pinning logic
  • Loading branch information
chriswhilar authored Feb 10, 2025
2 parents ef14700 + bdc3949 commit b22a1b9
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Project/src/MakeCall/CallCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -1390,11 +1390,14 @@ export default class CallCard extends React.Component {
}

handleVideoPin = (streamTuple, e) => {
// e.preventDefault();
const checked = e.target.checked;
const allRemoteParticipantStreams = this.state.allRemoteParticipantStreams;
// If there is already 2 streams pinned and the user is trying to pin another stream, return
if (allRemoteParticipantStreams.filter(streamTuple => streamTuple.isPinned).length >= 2 && checked) {
allRemoteParticipantStreams.find(v => v === streamTuple).isPinned = false;
this.setState({
allRemoteParticipantStreams: allRemoteParticipantStreams,
});
return;
}

Expand Down Expand Up @@ -2110,13 +2113,14 @@ export default class CallCard extends React.Component {
</div>
<div>
{this.state.allRemoteParticipantStreams.map((streamTuple) => (
streamTuple.participant.state === 'Connected' &&
<div key={utils.getIdentifierText(streamTuple.participant.identifier)}>
<input
type="checkbox"
checked={streamTuple.isPinned}
onChange={(e) => this.handleVideoPin(streamTuple, e)}
/>
{utils.getIdentifierText(streamTuple.participant.identifier)}
<input
type="checkbox"
checked={streamTuple.isPinned}
onChange={(e) => this.handleVideoPin(streamTuple, e)}
/>
{utils.getIdentifierText(streamTuple.participant.identifier)}
</div>
))}
</div>
Expand Down

0 comments on commit b22a1b9

Please sign in to comment.