From 4703903df0e55b332db8dac1cd80598a656b95a6 Mon Sep 17 00:00:00 2001 From: eswarclynn Date: Tue, 19 Mar 2024 03:17:08 +0530 Subject: [PATCH 1/5] fix: sidebar for whiteboard layout --- .../components/VideoLayouts/GridLayout.tsx | 31 +++++- .../VideoLayouts/WhiteboardLayout.tsx | 96 +++++++++++++++++++ .../layouts/VideoStreamingSection.tsx | 18 +--- .../src/Prebuilt/layouts/WhiteboardView.tsx | 69 ------------- 4 files changed, 124 insertions(+), 90 deletions(-) create mode 100644 packages/roomkit-react/src/Prebuilt/components/VideoLayouts/WhiteboardLayout.tsx delete mode 100644 packages/roomkit-react/src/Prebuilt/layouts/WhiteboardView.tsx diff --git a/packages/roomkit-react/src/Prebuilt/components/VideoLayouts/GridLayout.tsx b/packages/roomkit-react/src/Prebuilt/components/VideoLayouts/GridLayout.tsx index 6d64429aea..82b1d47186 100644 --- a/packages/roomkit-react/src/Prebuilt/components/VideoLayouts/GridLayout.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/VideoLayouts/GridLayout.tsx @@ -5,12 +5,14 @@ import { selectLocalPeerRoleName, selectPeers, selectPeerScreenSharing, + selectWhiteboard, useHMSStore, useHMSVanillaStore, } from '@100mslive/react-sdk'; import { EqualProminence } from './EqualProminence'; import { RoleProminence } from './RoleProminence'; import { ScreenshareLayout } from './ScreenshareLayout'; +import { WhiteboardLayout } from './WhiteboardLayout'; // @ts-ignore: No implicit Any import { usePinnedTrack, useSetAppDataByKey } from '../AppData/useUISettings'; import { VideoTileContext } from '../hooks/useVideoTileLayout'; @@ -40,6 +42,7 @@ export const GridLayout = ({ hide_metadata_on_tile = false, }: GridLayoutProps) => { const peerSharing = useHMSStore(selectPeerScreenSharing); + const whiteboard = useHMSStore(selectWhiteboard); const pinnedTrack = usePinnedTrack(); const peers = useHMSStore(selectPeers); const localPeerRole = useHMSStore(selectLocalPeerRoleName); @@ -53,9 +56,9 @@ export const GridLayout = ({ )) || pinnedTrack; const updatedPeers = useMemo(() => { - // remove screenshare peer from active speaker sorting - if (activeScreensharePeerId) { - return peers.filter(peer => peer.id !== activeScreensharePeerId); + // remove screenshare/whiteboard peer from active speaker sorting + if (activeScreensharePeerId || whiteboard?.open) { + return peers.filter(peer => peer.id !== activeScreensharePeerId || peer.customerUserId !== whiteboard?.owner); } if (isInsetEnabled) { const isLocalPeerPinned = localPeerID === pinnedTrack?.peerId; @@ -67,7 +70,16 @@ export const GridLayout = ({ } } return peers; - }, [isInsetEnabled, activeScreensharePeerId, localPeerRole, localPeerID, prominentRoles, peers, pinnedTrack]); + }, [ + isInsetEnabled, + whiteboard, + activeScreensharePeerId, + localPeerRole, + localPeerID, + prominentRoles, + peers, + pinnedTrack, + ]); const vanillaStore = useHMSVanillaStore(); const [sortedPeers, setSortedPeers] = useState(updatedPeers); const peersSorter = useMemo(() => new PeersSorter(vanillaStore), [vanillaStore]); @@ -104,6 +116,17 @@ export const GridLayout = ({ /> ); + } else if (whiteboard?.open) { + return ( + + + + ); } else if (isRoleProminence) { return ( diff --git a/packages/roomkit-react/src/Prebuilt/components/VideoLayouts/WhiteboardLayout.tsx b/packages/roomkit-react/src/Prebuilt/components/VideoLayouts/WhiteboardLayout.tsx new file mode 100644 index 0000000000..456e557092 --- /dev/null +++ b/packages/roomkit-react/src/Prebuilt/components/VideoLayouts/WhiteboardLayout.tsx @@ -0,0 +1,96 @@ +import React, { useEffect, useMemo } from 'react'; +import { useMedia } from 'react-use'; +import { selectPeerByCondition, selectWhiteboard, useHMSStore, useWhiteboard } from '@100mslive/react-sdk'; +import { Box } from '../../../Layout'; +import { config as cssConfig } from '../../../Theme'; +import { InsetTile } from '../InsetTile'; +import { SecondaryTiles } from '../SecondaryTiles'; +import { LayoutMode } from '../Settings/LayoutSettings'; +import { LayoutProps } from './interface'; +import { ProminenceLayout } from './ProminenceLayout'; +// @ts-ignore: No implicit Any +import { useSetUiSettings } from '../AppData/useUISettings'; +// @ts-ignore: No implicit Any +import { UI_SETTINGS } from '../../common/constants'; + +const WhiteboardEmbed = () => { + const isMobile = useMedia(cssConfig.media.md); + const { iframeRef } = useWhiteboard(isMobile); + + return ( + +