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: use correct layout prop for vb images #2372

Merged
merged 11 commits into from
Jan 3, 2024
4 changes: 2 additions & 2 deletions apps/100ms-custom-app/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions apps/100ms-web/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/hls-player/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/hls-stats/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/hms-noise-suppression/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/hms-video-store/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/hms-video-web/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/hms-virtual-background/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/react-icons/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/react-sdk/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions packages/roomkit-react/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState } from 'react';
import { HMSVirtualBackgroundTypes } from '@100mslive/hms-virtual-background';
import { VirtualBackground, VirtualBackgroundMedia } from '@100mslive/types-prebuilt/elements/virtual_background';
import { VirtualBackgroundMedia } from '@100mslive/types-prebuilt/elements/virtual_background';
import {
HMSRoomState,
selectIsLargeRoom,
Expand Down Expand Up @@ -28,7 +28,7 @@ import { defaultMedia, vbPlugin } from './constants';
const iconDims = { height: '40px', width: '40px' };
const MAX_RETRIES = 2;

export const VBPicker = ({ background_media = [] }: VirtualBackground = {}) => {
export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBackgroundMedia[] }) => {
const toggleVB = useSidepaneToggle(SIDE_PANE_OPTIONS.VB);
const hmsActions = useHMSActions();
const role = useHMSStore(selectLocalPeerRole);
Expand All @@ -46,7 +46,9 @@ export const VBPicker = ({ background_media = [] }: VirtualBackground = {}) => {
const roomState = useHMSStore(selectRoomState);
const isLargeRoom = useHMSStore(selectIsLargeRoom);
const addedPluginToVideoTrack = useRef(false);
const mediaList = [...background_media.map((media: VirtualBackgroundMedia) => media?.url), ...defaultMedia];
const mediaList = backgroundMedia.length
? backgroundMedia.map((media: VirtualBackgroundMedia) => media?.url)
: defaultMedia;

const inPreview = roomState === HMSRoomState.Preview;
// Hidden in preview as the effect will be visible in the preview tile. Needed inside the room because the peer might not be on-screen
Expand Down
8 changes: 6 additions & 2 deletions packages/roomkit-react/src/Prebuilt/layouts/SidePane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import { Box, Flex } from '../../Layout';
import { config as cssConfig } from '../../Theme';
// @ts-ignore: No implicit Any
import { useSidepaneReset } from '../components/AppData/useSidepane';
import { useRoomLayoutConferencingScreen } from '../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
import {
useRoomLayoutConferencingScreen,
useRoomLayoutPreviewScreen,
} from '../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
import { translateAcross } from '../../utils';
import { APP_DATA, SIDE_PANE_OPTIONS } from '../common/constants';

Expand All @@ -28,6 +31,7 @@ const SidePane = ({
const activeScreensharePeerId = useHMSStore(selectAppData(APP_DATA.activeScreensharePeerId));
const trackId = useHMSStore(selectVideoTrackByPeerID(activeScreensharePeerId))?.id;
const { elements } = useRoomLayoutConferencingScreen();
const { elements: preview_elements } = useRoomLayoutPreviewScreen();
const resetSidePane = useSidepaneReset();
let ViewComponent;
if (sidepane === SIDE_PANE_OPTIONS.POLLS) {
Expand All @@ -37,7 +41,7 @@ const SidePane = ({
ViewComponent = <SidePaneTabs hideControls={hideControls} active={sidepane} />;
}
if (sidepane === SIDE_PANE_OPTIONS.VB) {
ViewComponent = <VBPicker {...elements.virtual_background} />;
ViewComponent = <VBPicker backgroundMedia={preview_elements?.virtual_background?.background_media || []} />;
}

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import type { Layout } from '@100mslive/types-prebuilt';
import merge from 'lodash.merge';
import { isArray, mergeWith } from 'lodash';
// @ts-ignore: fix types
import { useAuthToken } from '../../components/AppData/useUISettings';
import { useFetchRoomLayout, useFetchRoomLayoutResponse } from './hooks/useFetchRoomLayout';
Expand All @@ -18,14 +18,22 @@ export const RoomLayoutContext = React.createContext<
| undefined
>(undefined);

function customizer(objValue: any, srcValue: any) {
if (isArray(objValue) && isArray(srcValue)) {
KaustubhKumar05 marked this conversation as resolved.
Show resolved Hide resolved
return srcValue;
}
// default mergeWith behaviour is followed
return undefined;
}

export const RoomLayoutProvider: React.FC<React.PropsWithChildren<RoomLayoutProviderProps>> = ({
children,
roomLayoutEndpoint,
overrideLayout,
}) => {
const authToken: string = useAuthToken();
const { layout, updateRoomLayoutForRole } = useFetchRoomLayout({ authToken, endpoint: roomLayoutEndpoint });
const mergedLayout = authToken && layout ? merge(layout, overrideLayout) : layout;
const mergedLayout = authToken && layout ? mergeWith(layout, overrideLayout, customizer) : layout;
return (
<RoomLayoutContext.Provider value={{ layout: mergedLayout, updateRoomLayoutForRole }}>
{children}
Expand Down
4 changes: 2 additions & 2 deletions packages/roomkit-web/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading