Skip to content

Commit 7133187

Browse files
committed
Fix issues where together mode stream keeps loading unitl views are changed
1 parent 3e69c6a commit 7133187

6 files changed

Lines changed: 86 additions & 76 deletions

File tree

packages/calling-component-bindings/src/utils/videoGalleryUtils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,8 @@ export const memoizeTogetherModeStreams = memoizeOne((togetherModeStreams) => ({
262262
streamSize: togetherModeStreams?.mainVideoStream?.streamSize
263263
}
264264
}));
265+
266+
/** @private */
267+
export const memoizeTogetherModeSeatingPositions = memoizeOne(
268+
(togetherModeSeatingCoordinates) => togetherModeSeatingCoordinates
269+
);

packages/calling-component-bindings/src/videoGallerySelector.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ import {
3232
_dominantSpeakersWithFlatId,
3333
convertRemoteParticipantToVideoGalleryRemoteParticipant,
3434
memoizeLocalParticipant,
35-
/* @conditional-compile-remove(together-mode) */ memoizeTogetherModeStreams
35+
/* @conditional-compile-remove(together-mode) */ memoizeTogetherModeStreams,
36+
/* @conditional-compile-remove(together-mode) */ memoizeTogetherModeSeatingPositions
3637
} from './utils/videoGalleryUtils';
3738
import { memoizeSpotlightedParticipantIds } from './utils/videoGalleryUtils';
3839
import { getLocalParticipantRaisedHand } from './baseSelectors';
@@ -165,7 +166,7 @@ export const videoGallerySelector: VideoGallerySelector = createSelector(
165166
/* @conditional-compile-remove(together-mode) */
166167
togetherModeStreams: memoizeTogetherModeStreams(togetherModeCallFeature?.streams),
167168
/* @conditional-compile-remove(together-mode) */
168-
togetherModeSeatingCoordinates: togetherModeCallFeature?.seatingPositions,
169+
togetherModeSeatingCoordinates: memoizeTogetherModeSeatingPositions(togetherModeCallFeature?.seatingPositions),
169170
/* @conditional-compile-remove(together-mode) */
170171
isTogetherModeActive: togetherModeCallFeature?.isActive,
171172
/* @conditional-compile-remove(together-mode) */

packages/react-components/src/components/VideoGallery.tsx

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -822,24 +822,26 @@ export const VideoGallery = (props: VideoGalleryProps): JSX.Element => {
822822

823823
/* @conditional-compile-remove(together-mode) */
824824
const togetherModeStreamComponent = useMemo(
825-
() => (
826-
<TogetherModeStream
827-
startTogetherModeEnabled={startTogetherModeEnabled}
828-
isTogetherModeActive={isTogetherModeActive}
829-
onCreateTogetherModeStreamView={onCreateTogetherModeStreamView}
830-
onStartTogetherMode={onStartTogetherMode}
831-
onDisposeTogetherModeStreamView={onDisposeTogetherModeStreamView}
832-
onSetTogetherModeSceneSize={onSetTogetherModeSceneSize}
833-
togetherModeStreams={togetherModeStreams}
834-
seatingCoordinates={togetherModeSeatingCoordinates}
835-
localParticipant={localParticipant}
836-
remoteParticipants={remoteParticipants}
837-
reactionResources={reactionResources}
838-
containerWidth={containerWidth}
839-
containerHeight={containerHeight}
840-
/>
841-
),
825+
() =>
826+
!screenShareComponent ? (
827+
<TogetherModeStream
828+
startTogetherModeEnabled={startTogetherModeEnabled}
829+
isTogetherModeActive={isTogetherModeActive}
830+
onCreateTogetherModeStreamView={onCreateTogetherModeStreamView}
831+
onStartTogetherMode={onStartTogetherMode}
832+
onDisposeTogetherModeStreamView={onDisposeTogetherModeStreamView}
833+
onSetTogetherModeSceneSize={onSetTogetherModeSceneSize}
834+
togetherModeStreams={togetherModeStreams}
835+
seatingCoordinates={togetherModeSeatingCoordinates}
836+
localParticipant={localParticipant}
837+
remoteParticipants={remoteParticipants}
838+
reactionResources={reactionResources}
839+
containerWidth={containerWidth}
840+
containerHeight={containerHeight}
841+
/>
842+
) : undefined,
842843
[
844+
screenShareComponent,
843845
startTogetherModeEnabled,
844846
isTogetherModeActive,
845847
onCreateTogetherModeStreamView,
@@ -855,11 +857,6 @@ export const VideoGallery = (props: VideoGalleryProps): JSX.Element => {
855857
containerHeight
856858
]
857859
);
858-
/* @conditional-compile-remove(together-mode) */
859-
// Current implementation of capabilities is only based on user role.
860-
// This logic checks for the user role and if the user is a Teams user.
861-
const canSwitchToTogetherModeLayout =
862-
isTogetherModeActive || (_isIdentityMicrosoftTeamsUser(localParticipant.userId) && startTogetherModeEnabled);
863860

864861
const layoutProps = useMemo<LayoutProps>(
865862
() => ({
@@ -877,7 +874,8 @@ export const VideoGallery = (props: VideoGalleryProps): JSX.Element => {
877874
pinnedParticipantUserIds: pinnedParticipants,
878875
overflowGalleryPosition,
879876
localVideoTileSize,
880-
spotlightedParticipantUserIds: spotlightedParticipants
877+
spotlightedParticipantUserIds: spotlightedParticipants,
878+
togetherModeStreamComponent
881879
}),
882880
[
883881
remoteParticipants,
@@ -895,7 +893,8 @@ export const VideoGallery = (props: VideoGalleryProps): JSX.Element => {
895893
pinnedParticipants,
896894
overflowGalleryPosition,
897895
localVideoTileSize,
898-
spotlightedParticipants
896+
spotlightedParticipants,
897+
togetherModeStreamComponent
899898
]
900899
);
901900

@@ -917,17 +916,15 @@ export const VideoGallery = (props: VideoGalleryProps): JSX.Element => {
917916
/* @conditional-compile-remove(together-mode) */
918917
// Teams users can switch to Together mode layout only if they have the capability,
919918
// while ACS users can do so only if Together mode is enabled.
920-
if (!screenShareComponent && layout === 'togetherMode' && canSwitchToTogetherModeLayout) {
921-
return <TogetherModeLayout togetherModeStreamComponent={togetherModeStreamComponent} />;
919+
if (layoutProps.togetherModeStreamComponent && layout === 'togetherMode') {
920+
return <TogetherModeLayout togetherModeStreamComponent={layoutProps.togetherModeStreamComponent} />;
922921
}
923922
return <DefaultLayout {...layoutProps} />;
924923
}, [
925-
/* @conditional-compile-remove(together-mode) */ canSwitchToTogetherModeLayout,
924+
// /* @conditional-compile-remove(together-mode) */ canSwitchToTogetherModeLayout,
926925
layout,
927926
layoutProps,
928-
screenShareComponent,
929-
screenShareParticipant,
930-
/* @conditional-compile-remove(together-mode) */ togetherModeStreamComponent
927+
screenShareParticipant
931928
]);
932929

933930
return (

packages/react-components/src/components/VideoGallery/TogetherModeStream.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
TogetherModeStreamViewResult,
1414
VideoGalleryLocalParticipant,
1515
VideoGalleryRemoteParticipant,
16-
VideoStreamOptions
16+
VideoStreamOptions,
17+
TogetherModeStreamOptions
1718
} from '../../types';
1819
/* @conditional-compile-remove(together-mode) */
1920
import { StreamMedia } from '../StreamMedia';
@@ -33,7 +34,9 @@ export const TogetherModeStream = memo(
3334
(props: {
3435
startTogetherModeEnabled?: boolean;
3536
isTogetherModeActive?: boolean;
36-
onCreateTogetherModeStreamView?: (options?: VideoStreamOptions) => Promise<void | TogetherModeStreamViewResult>;
37+
onCreateTogetherModeStreamView?: (
38+
options?: TogetherModeStreamOptions
39+
) => Promise<void | TogetherModeStreamViewResult>;
3740
onStartTogetherMode?: (options?: VideoStreamOptions) => Promise<void | TogetherModeStreamViewResult>;
3841
onDisposeTogetherModeStreamView?: () => Promise<void>;
3942
onSetTogetherModeSceneSize?: (width: number, height: number) => void;
@@ -73,10 +76,14 @@ export const TogetherModeStream = memo(
7376

7477
// Create stream view if not already created
7578
useEffect(() => {
76-
if (!togetherModeStreams?.mainVideoStream?.renderElement) {
79+
if (togetherModeStreams?.mainVideoStream?.isAvailable && !togetherModeStreams?.mainVideoStream?.renderElement) {
7780
onCreateTogetherModeStreamView?.();
7881
}
79-
}, [togetherModeStreams?.mainVideoStream?.renderElement, onCreateTogetherModeStreamView]);
82+
}, [
83+
togetherModeStreams?.mainVideoStream?.renderElement,
84+
togetherModeStreams?.mainVideoStream?.isAvailable,
85+
onCreateTogetherModeStreamView
86+
]);
8087

8188
// Update scene size only when container dimensions change
8289
useMemo(() => {

packages/react-composites/src/composites/common/ControlBar/DesktopMoreButton.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -410,27 +410,27 @@ export const DesktopMoreButton = (props: DesktopMoreButtonProps): JSX.Element =>
410410
};
411411

412412
/* @conditional-compile-remove(together-mode) */
413-
const togetherModeOption = {
414-
key: 'togetherModeSelectionKey',
415-
text: localeStrings.strings.call.moreButtonTogetherModeLayoutLabel,
416-
canCheck: true,
417-
itemProps: {
418-
styles: buttonFlyoutIncreasedSizeStyles
419-
},
420-
isChecked: props.userSetGalleryLayout === 'togetherMode',
421-
onClick: () => {
422-
props.onUserSetGalleryLayout && props.onUserSetGalleryLayout('togetherMode');
423-
setFocusedContentOn(false);
424-
},
425-
disabled: !(
426-
(participantId?.kind === 'microsoftTeamsUser' && participantCapability?.startTogetherMode?.isPresent) ||
427-
isTogetherModeActive
428-
),
429-
iconProps: {
430-
iconName: 'TogetherModeLayout',
431-
styles: { root: { lineHeight: 0 } }
432-
}
433-
};
413+
const togetherModeOption =
414+
(participantId?.kind === 'microsoftTeamsUser' && participantCapability?.startTogetherMode?.isPresent) ||
415+
isTogetherModeActive
416+
? {
417+
key: 'togetherModeSelectionKey',
418+
text: localeStrings.strings.call.moreButtonTogetherModeLayoutLabel,
419+
canCheck: true,
420+
itemProps: {
421+
styles: buttonFlyoutIncreasedSizeStyles
422+
},
423+
isChecked: props.userSetGalleryLayout === 'togetherMode',
424+
onClick: () => {
425+
props.onUserSetGalleryLayout && props.onUserSetGalleryLayout('togetherMode');
426+
setFocusedContentOn(false);
427+
},
428+
iconProps: {
429+
iconName: 'TogetherModeLayout',
430+
styles: { root: { lineHeight: 0 } }
431+
}
432+
}
433+
: undefined;
434434

435435
/* @conditional-compile-remove(overflow-top-composite) */
436436
const overflowGalleryOption = {
@@ -463,7 +463,7 @@ export const DesktopMoreButton = (props: DesktopMoreButtonProps): JSX.Element =>
463463
/* @conditional-compile-remove(overflow-top-composite) */
464464
galleryOptions.subMenuProps?.items?.push(overflowGalleryOption);
465465
/* @conditional-compile-remove(together-mode) */
466-
if (isTeamsCall || isTeamsMeeting) {
466+
if (togetherModeOption && (isTeamsCall || isTeamsMeeting)) {
467467
galleryOptions.subMenuProps?.items?.push(togetherModeOption);
468468
}
469469
if (props.callControls === true || (props.callControls as CallControlOptions)?.galleryControlsButton !== false) {

packages/react-composites/src/composites/common/Drawer/MoreDrawer.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -402,28 +402,28 @@ export const MoreDrawer = (props: MoreDrawerProps): JSX.Element => {
402402
};
403403

404404
/* @conditional-compile-remove(together-mode) */
405-
const togetherModeOption = {
406-
itemKey: 'togetherModeSelectionKey',
407-
text: localeStrings.strings.call.moreButtonTogetherModeLayoutLabel,
408-
onItemClick: () => {
409-
props.onUserSetGalleryLayout && props.onUserSetGalleryLayout('togetherMode');
410-
onLightDismiss();
411-
},
412-
iconProps: {
413-
iconName: 'TogetherModeLayout',
414-
styles: { root: { lineHeight: 0 } }
415-
},
416-
disabled: !(
417-
(participantId?.kind === 'microsoftTeamsUser' && participantCapability?.startTogetherMode?.isPresent) ||
418-
isTogetherModeActive
419-
),
420-
secondaryIconProps: props.userSetGalleryLayout === 'default' ? { iconName: 'Accept' } : undefined
421-
};
405+
const togetherModeOption =
406+
(participantId?.kind === 'microsoftTeamsUser' && participantCapability?.startTogetherMode?.isPresent) ||
407+
isTogetherModeActive
408+
? {
409+
itemKey: 'togetherModeSelectionKey',
410+
text: localeStrings.strings.call.moreButtonTogetherModeLayoutLabel,
411+
onItemClick: () => {
412+
props.onUserSetGalleryLayout && props.onUserSetGalleryLayout('togetherMode');
413+
onLightDismiss();
414+
},
415+
iconProps: {
416+
iconName: 'TogetherModeLayout',
417+
styles: { root: { lineHeight: 0 } }
418+
},
419+
secondaryIconProps: props.userSetGalleryLayout === 'default' ? { iconName: 'Accept' } : undefined
420+
}
421+
: undefined;
422422

423423
/* @conditional-compile-remove(gallery-layout-composite) */
424424
galleryLayoutOptions.subMenuProps?.push(galleryOption);
425425
/* @conditional-compile-remove(together-mode) */
426-
if (isTeamsCall || isTeamsMeeting) {
426+
if (togetherModeOption && (isTeamsCall || isTeamsMeeting)) {
427427
galleryLayoutOptions.subMenuProps?.push(togetherModeOption);
428428
}
429429

0 commit comments

Comments
 (0)