From 0b7241082832a3b09dc40790d5632a01436051da Mon Sep 17 00:00:00 2001 From: harshithpabbati Date: Fri, 7 Jan 2022 16:57:05 +0530 Subject: [PATCH] Hide screenshare, recording, livestreaming options to non owner participants --- custom/fitness-demo/components/Tray/Record.js | 7 +++++++ custom/fitness-demo/components/Tray/ScreenShare.js | 3 ++- custom/fitness-demo/components/Tray/Stream.js | 4 ++++ custom/fitness-demo/components/Tray/View.js | 4 +++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/custom/fitness-demo/components/Tray/Record.js b/custom/fitness-demo/components/Tray/Record.js index b4ac465..9a3b37a 100644 --- a/custom/fitness-demo/components/Tray/Record.js +++ b/custom/fitness-demo/components/Tray/Record.js @@ -1,6 +1,8 @@ import React, { useEffect } from 'react'; import { TrayButton } from '@custom/shared/components/Tray'; +import { useCallState } from '@custom/shared/contexts/CallProvider'; +import { useParticipants } from '@custom/shared/contexts/ParticipantsProvider'; import { useUIState } from '@custom/shared/contexts/UIStateProvider'; import { ReactComponent as IconRecord } from '@custom/shared/icons/record-md.svg'; @@ -14,8 +16,10 @@ import { import { RECORDING_MODAL } from '../Modals/RecordingModal'; export const Tray = () => { + const { enableRecording } = useCallState(); const { openModal } = useUIState(); const { recordingState } = useRecording(); + const { localParticipant } = useParticipants(); useEffect(() => { console.log(`⏺️ Recording state: ${recordingState}`); @@ -31,6 +35,9 @@ export const Tray = () => { RECORDING_SAVED, ].includes(recordingState); + if (!enableRecording) return null; + if (!localParticipant.isOwner) return null; + return ( { const { callObject, enableScreenShare } = useCallState(); - const { screens, participants } = useParticipants(); + const { screens, participants, localParticipant } = useParticipants(); const isSharingScreen = useMemo( () => screens.some((s) => s.isLocal), @@ -27,6 +27,7 @@ export const ScreenShareTray = () => { !isSharingScreen; if (!enableScreenShare) return null; + if (!localParticipant.isOwner) return null; return ( { const { openModal } = useUIState(); const { isStreaming } = useLiveStreaming(); + const { localParticipant } = useParticipants(); + + if (!localParticipant.isOwner) return null; return ( { - const { participants } = useParticipants(); + const { participants, localParticipant } = useParticipants(); const { viewMode, setPreferredViewMode } = useUIState(); const onViewClick = () => setPreferredViewMode(viewMode === VIEW_MODE_SPEAKER ? VIEW_MODE_GRID : VIEW_MODE_SPEAKER); + if (!localParticipant.isOwner) return null; + return (