From 3d7ee93fb30041ec571b60db8938659c624b0bad Mon Sep 17 00:00:00 2001 From: harshithpabbati Date: Fri, 7 Jan 2022 14:17:08 +0530 Subject: [PATCH] Fix issue with screen share --- .../fitness-demo/components/Call/VideoView.js | 11 +- .../components/GridView/GridView.js | 36 +++--- .../ScreensAndPins/ScreenPinTile.js | 42 +++++++ .../ScreensAndPins/ScreensAndPins.js | 105 ++++++++++++++++++ .../SpeakerView/ScreensAndPins/index.js | 1 + .../SpeakerView/SpeakerTile/SpeakerTile.js | 5 +- .../components/SpeakerView/SpeakerView.js | 14 ++- custom/fitness-demo/components/Tray/View.js | 6 +- 8 files changed, 186 insertions(+), 34 deletions(-) create mode 100644 custom/fitness-demo/components/SpeakerView/ScreensAndPins/ScreenPinTile.js create mode 100644 custom/fitness-demo/components/SpeakerView/ScreensAndPins/ScreensAndPins.js create mode 100644 custom/fitness-demo/components/SpeakerView/ScreensAndPins/index.js diff --git a/custom/fitness-demo/components/Call/VideoView.js b/custom/fitness-demo/components/Call/VideoView.js index 93e3118..167e6c5 100644 --- a/custom/fitness-demo/components/Call/VideoView.js +++ b/custom/fitness-demo/components/Call/VideoView.js @@ -1,12 +1,17 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { useParticipants } from '@custom/shared/contexts/ParticipantsProvider'; import { useUIState, VIEW_MODE_SPEAKER } from '@custom/shared/contexts/UIStateProvider'; import { GridView } from '../GridView/GridView'; import { SpeakerView } from '../SpeakerView'; export const VideoView = () => { - const { viewMode } = useUIState(); - const { participants } = useParticipants(); + const { viewMode, setIsShowingScreenshare } = useUIState(); + const { participants, screens } = useParticipants(); + + useEffect(() => { + const hasScreens = screens.length > 0; + setIsShowingScreenshare(hasScreens); + }, [screens, setIsShowingScreenshare]); if (!participants.length) return null; return viewMode === VIEW_MODE_SPEAKER ? : ; diff --git a/custom/fitness-demo/components/GridView/GridView.js b/custom/fitness-demo/components/GridView/GridView.js index 4a3fe25..dbd3440 100644 --- a/custom/fitness-demo/components/GridView/GridView.js +++ b/custom/fitness-demo/components/GridView/GridView.js @@ -295,25 +295,25 @@ export const GridView = ({ return (
- - + {(pages > 1 && page > 1) && ( + + )}
{tiles}
- - + {(pages > 1 && page < pages) && ( + + )} +
+ ); +}; + +export default ScreensAndPins; \ No newline at end of file diff --git a/custom/fitness-demo/components/SpeakerView/ScreensAndPins/index.js b/custom/fitness-demo/components/SpeakerView/ScreensAndPins/index.js new file mode 100644 index 0000000..228aada --- /dev/null +++ b/custom/fitness-demo/components/SpeakerView/ScreensAndPins/index.js @@ -0,0 +1 @@ +export { ScreensAndPins } from './ScreensAndPins'; \ No newline at end of file diff --git a/custom/fitness-demo/components/SpeakerView/SpeakerTile/SpeakerTile.js b/custom/fitness-demo/components/SpeakerView/SpeakerTile/SpeakerTile.js index b651402..c69a8e8 100644 --- a/custom/fitness-demo/components/SpeakerView/SpeakerTile/SpeakerTile.js +++ b/custom/fitness-demo/components/SpeakerView/SpeakerTile/SpeakerTile.js @@ -18,10 +18,7 @@ export const SpeakerTile = ({ participant, screenRef }) => { setScreenHeight(rect.height); }, [screenRef]); - useResize(() => { - updateRatio(); - }, [updateRatio]); - + useResize(() => updateRatio(), [updateRatio]); useEffect(() => updateRatio(), [updateRatio]); /** diff --git a/custom/fitness-demo/components/SpeakerView/SpeakerView.js b/custom/fitness-demo/components/SpeakerView/SpeakerView.js index 2aaeb1c..3eccd37 100644 --- a/custom/fitness-demo/components/SpeakerView/SpeakerView.js +++ b/custom/fitness-demo/components/SpeakerView/SpeakerView.js @@ -1,13 +1,11 @@ import React, { useEffect, useMemo, useRef } from 'react'; -import { Container } from '@custom/basic-call/components/Call/Container'; -import Header from '@custom/basic-call/components/Call/Header'; import ParticipantBar from '@custom/shared/components/ParticipantBar/ParticipantBar'; -import VideoContainer from '@custom/shared/components/VideoContainer/VideoContainer'; import { useCallState } from '@custom/shared/contexts/CallProvider'; import { useParticipants } from '@custom/shared/contexts/ParticipantsProvider'; import { useTracks } from '@custom/shared/contexts/TracksProvider'; import { useUIState } from '@custom/shared/contexts/UIStateProvider'; import { isScreenId } from '@custom/shared/contexts/participantsState'; +import { ScreensAndPins } from './ScreensAndPins'; import { SpeakerTile } from './SpeakerTile'; const SIDEBAR_WIDTH = 186; @@ -40,10 +38,10 @@ export const SpeakerView = () => { return participants.length > 1 || hasScreenshares; }, [participants, pinnedId, screens]); - /* const screenShareTiles = useMemo( + const screenShareTiles = useMemo( () => , [screensAndPinned] - ); */ + ); const hasScreenshares = useMemo(() => screens.length > 0, [screens]); @@ -80,7 +78,11 @@ export const SpeakerView = () => { return (
- + {screensAndPinned.length > 0 ? ( + screenShareTiles + ) : ( + + )}
{showSidebar && ( { const { participants } = useParticipants(); const { viewMode, setPreferredViewMode } = useUIState(); - const onClick = () => - setPreferredViewMode(viewMode === VIEW_MODE_SPEAKER ? VIEW_MODE_GRID: VIEW_MODE_SPEAKER); + const onViewClick = () => + setPreferredViewMode(viewMode === VIEW_MODE_SPEAKER ? VIEW_MODE_GRID : VIEW_MODE_SPEAKER); return ( {viewMode === VIEW_MODE_SPEAKER ? : }