Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pinned participant limit to update when pinned participants are removed from call #4761

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "patch",
"area": "fix",
"workstream": "Pinned participants",
"comment": "Fix pinned participant limit to update correctly when pinned participants are removed from call",
"packageName": "@azure/communication-react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "patch",
"area": "fix",
"workstream": "Pinned participants",
"comment": "Fix pinned participant limit to update correctly when pinned participants are removed from call",
"packageName": "@azure/communication-react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
15 changes: 11 additions & 4 deletions packages/react-components/src/components/VideoGallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,14 @@ export const VideoGallery = (props: VideoGalleryProps): JSX.Element => {
});
}, [props.pinnedParticipants, props.remoteParticipants]);
// Use pinnedParticipants from props but if it is not defined use the maintained state of pinned participants
const pinnedParticipants = props.pinnedParticipants ?? pinnedParticipantsState;
const pinnedParticipants = useMemo(
() =>
props.pinnedParticipants ??
pinnedParticipantsState.filter((pinnedParticipantId) =>
remoteParticipants.find((remoteParticipant) => remoteParticipant.userId === pinnedParticipantId)
),
[props.pinnedParticipants, pinnedParticipantsState, remoteParticipants]
);

const showLocalVideoTileLabel =
!((localTileNotInGrid && isNarrow) || localVideoTileSize === '9:16') || layout === 'default';
Expand Down Expand Up @@ -547,12 +554,12 @@ export const VideoGallery = (props: VideoGalleryProps): JSX.Element => {
if (pinnedParticipants.length >= MAX_PINNED_REMOTE_VIDEO_TILES) {
return;
}
if (!pinnedParticipantsState.includes(userId)) {
setPinnedParticipantsState(pinnedParticipantsState.concat(userId));
if (!pinnedParticipants.includes(userId)) {
setPinnedParticipantsState(pinnedParticipants.concat(userId));
}
onPinParticipantHandler?.(userId);
},
[pinnedParticipants.length, pinnedParticipantsState, setPinnedParticipantsState, onPinParticipantHandler]
[pinnedParticipants, setPinnedParticipantsState, onPinParticipantHandler]
);
const onUnpinParticipant = useCallback(
(userId: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ActiveErrorMessage, ErrorBar, ParticipantMenuItemsCallback } from '@int
/* @conditional-compile-remove(notifications) */
import { ActiveNotification } from '@internal/react-components';
import { VideoGalleryLayout } from '@internal/react-components';
import React from 'react';
import React, { useMemo } from 'react';
import { useState } from 'react';
import { AvatarPersonaDataCallback } from '../../common/AvatarPersona';
import { useLocale } from '../../localization';
Expand All @@ -34,6 +34,7 @@ import { DtmfDialpadPage } from './DtmfDialpadPage';
import { showDtmfDialer } from '../utils/MediaGalleryUtils';
import { getTargetCallees } from '../selectors/baseSelectors';
import { Prompt, PromptProps } from '../components/Prompt';
import { toFlatCommunicationIdentifier } from '@internal/acs-ui-common';

/**
* @private
Expand Down Expand Up @@ -78,7 +79,7 @@ export const CallPage = (props: CallPageProps): JSX.Element => {
userSetOverflowGalleryPosition = 'Responsive',
onSetUserSetOverflowGalleryPosition,
onCloseChatPane,
pinnedParticipants,
pinnedParticipants = [],
setPinnedParticipants,
compositeAudioContext,
disableAutoShowDtmfDialer = false
Expand All @@ -102,6 +103,16 @@ export const CallPage = (props: CallPageProps): JSX.Element => {

const strings = useLocale().strings.call;

const pinnedParticipantsChecked = useMemo(
() =>
pinnedParticipants.filter((pinnedParticipant) =>
remoteParticipantsConnected.find(
(remoteParticipant) => toFlatCommunicationIdentifier(remoteParticipant.identifier) === pinnedParticipant
)
),
[pinnedParticipants, remoteParticipantsConnected]
);

// Reduce the controls shown when mobile view is enabled.
const callControlOptions = mobileView ? reduceCallControlsForMobile(options?.callControls) : options?.callControls;

Expand Down Expand Up @@ -138,7 +149,7 @@ export const CallPage = (props: CallPageProps): JSX.Element => {
localVideoTileOptions={options?.localVideoTile}
userSetOverflowGalleryPosition={userSetOverflowGalleryPosition}
userSetGalleryLayout={galleryLayout}
pinnedParticipants={pinnedParticipants}
pinnedParticipants={pinnedParticipantsChecked}
setPinnedParticipants={setPinnedParticipants}
setIsPromptOpen={setIsPromptOpen}
setPromptProps={setPromptProps}
Expand Down Expand Up @@ -193,7 +204,7 @@ export const CallPage = (props: CallPageProps): JSX.Element => {
setIsPromptOpen={setIsPromptOpen}
setPromptProps={setPromptProps}
hideSpotlightButtons={options?.spotlight?.hideSpotlightButtons}
pinnedParticipants={pinnedParticipants}
pinnedParticipants={pinnedParticipantsChecked}
setPinnedParticipants={setPinnedParticipants}
/>
{<Prompt isOpen={isPromptOpen} onDismiss={() => setIsPromptOpen(false)} {...promptProps} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,9 @@ const VideoGalleryStory = (args): JSX.Element => {
.split(',')
.map((p) => p.trim())
.filter((p) => p)
.map((p, i) => {
.map((p) => {
return {
userId: `user${i}`,
userId: `userId-${p}`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to change the id because when I test this fix on storybook preview it did not work. When I remove pinned participant 'Daryl' with user id 'user2', someone else would then take user id 'user2' because we assign them to our test participants sequentially.

displayName: p,
videoStream: { isAvailable: true }
};
Expand Down
Loading