From b76f346304f3e62e162587749b6a0d2d218b931e Mon Sep 17 00:00:00 2001 From: Kaustubh Kumar Date: Thu, 21 Mar 2024 11:24:47 +0530 Subject: [PATCH] Revert "feat: configure hand raise from layout config" This reverts commit 0d6968f2314a2f0839a0d34e27eebb0fd5cf115a. --- packages/roomkit-react/package.json | 2 +- .../Prebuilt/components/Chat/ChatFooter.tsx | 6 ++- .../Prebuilt/components/ConferenceScreen.tsx | 5 ++- .../src/Prebuilt/components/Footer/Footer.tsx | 5 ++- .../SplitComponents/DesktopOptions.tsx | 1 + .../SplitComponents/MwebOptions.tsx | 6 ++- .../components/PreviousRoleInMetadata.tsx | 1 + .../src/Prebuilt/components/RaiseHand.tsx | 8 +--- .../RoleChangeRequestModal.tsx | 1 + .../{useMetadata.tsx => useMetadata.jsx} | 10 ++++- yarn.lock | 39 +++++++++++++++---- 11 files changed, 62 insertions(+), 22 deletions(-) rename packages/roomkit-react/src/Prebuilt/components/hooks/{useMetadata.tsx => useMetadata.jsx} (91%) diff --git a/packages/roomkit-react/package.json b/packages/roomkit-react/package.json index 1770067ca6..79799bbb43 100644 --- a/packages/roomkit-react/package.json +++ b/packages/roomkit-react/package.json @@ -87,7 +87,7 @@ "@100mslive/hms-virtual-background": "1.13.2", "@100mslive/react-icons": "0.10.2", "@100mslive/react-sdk": "0.10.2", - "@100mslive/types-prebuilt": "0.12.8", + "@100mslive/types-prebuilt": "0.12.7", "@emoji-mart/data": "^1.0.6", "@emoji-mart/react": "^1.0.1", "@radix-ui/react-accordion": "1.0.0", diff --git a/packages/roomkit-react/src/Prebuilt/components/Chat/ChatFooter.tsx b/packages/roomkit-react/src/Prebuilt/components/Chat/ChatFooter.tsx index 51f51f2123..e581149b27 100644 --- a/packages/roomkit-react/src/Prebuilt/components/Chat/ChatFooter.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/Chat/ChatFooter.tsx @@ -2,7 +2,7 @@ import React, { ReactNode, useCallback, useEffect, useRef, useState } from 'reac import { useMedia } from 'react-use'; import data from '@emoji-mart/data'; import Picker from '@emoji-mart/react'; -import { HMSException, selectLocalPeer, useHMSActions, useHMSStore } from '@100mslive/react-sdk'; +import { HMSException, selectLocalPeer, useAVToggle, useHMSActions, useHMSStore } from '@100mslive/react-sdk'; import { EmojiIcon, PauseCircleIcon, SendIcon, VerticalMenuIcon } from '@100mslive/react-icons'; import { Box, config as cssConfig, Flex, IconButton as BaseIconButton, Popover, styled, Text } from '../../..'; import { IconButton } from '../../../IconButton'; @@ -89,6 +89,8 @@ export const ChatFooter = ({ onSend, children }: { onSend: (count: number) => vo const defaultSelection = useDefaultChatSelection(); const selection = selectedPeer.name || selectedRole || defaultSelection; const isLocalPeerBlacklisted = useIsPeerBlacklisted({ local: true }); + const { toggleAudio, toggleVideo } = useAVToggle(); + const noAVPermissions = !(toggleAudio || toggleVideo); const isMwebHLSStream = useMobileHLSStream(); const isLandscapeHLSStream = useLandscapeHLSStream(); @@ -273,7 +275,7 @@ export const ChatFooter = ({ onSend, children }: { onSend: (count: number) => vo }} gap="2" > - + {noAVPermissions ? : null} diff --git a/packages/roomkit-react/src/Prebuilt/components/ConferenceScreen.tsx b/packages/roomkit-react/src/Prebuilt/components/ConferenceScreen.tsx index b75aebe5fe..093766b05f 100644 --- a/packages/roomkit-react/src/Prebuilt/components/ConferenceScreen.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/ConferenceScreen.tsx @@ -6,6 +6,7 @@ import { selectAppData, selectIsConnectedToRoom, selectRoomState, + useAVToggle, useHMSActions, useHMSStore, } from '@100mslive/react-sdk'; @@ -53,6 +54,8 @@ export const ConferenceScreen = () => { const dropdownListRef = useRef(); const [isHLSStarted] = useSetAppDataByKey(APP_DATA.hlsStarted); + const { toggleAudio, toggleVideo } = useAVToggle(); + const noAVPermissions = !(toggleAudio || toggleVideo); // using it in hls stream to show action button when chat is disabled const showChat = !!screenProps.elements?.chat; const autoRoomJoined = useRef(isPreviewScreenEnabled); @@ -199,7 +202,7 @@ export const ConferenceScreen = () => { justify="end" gap="2" > - + {noAVPermissions ? : null} {isMobile ? ( <> - + {noAVPermissions ? : null} {elements?.chat && } diff --git a/packages/roomkit-react/src/Prebuilt/components/MoreSettings/SplitComponents/DesktopOptions.tsx b/packages/roomkit-react/src/Prebuilt/components/MoreSettings/SplitComponents/DesktopOptions.tsx index 2ade46c99d..697f30e7cd 100644 --- a/packages/roomkit-react/src/Prebuilt/components/MoreSettings/SplitComponents/DesktopOptions.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/MoreSettings/SplitComponents/DesktopOptions.tsx @@ -29,6 +29,7 @@ import { FullScreenItem } from '../FullScreenItem'; import { MuteAllModal } from '../MuteAllModal'; // @ts-ignore: No implicit any import { useDropdownList } from '../../hooks/useDropdownList'; +// @ts-ignore: No implicit any import { useMyMetadata } from '../../hooks/useMetadata'; // @ts-ignore: No implicit any import { APP_DATA, isMacOS } from '../../../common/constants'; diff --git a/packages/roomkit-react/src/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.tsx b/packages/roomkit-react/src/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.tsx index 30cb6393fb..aefd7b5a0b 100644 --- a/packages/roomkit-react/src/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.tsx @@ -6,6 +6,7 @@ import { selectIsConnectedToRoom, selectPeerCount, selectPermissions, + useAVToggle, useHMSActions, useHMSStore, useRecordingStreaming, @@ -50,6 +51,7 @@ import { usePollViewToggle, useSidepaneToggle } from '../../AppData/useSidepane' import { useShowPolls } from '../../AppData/useUISettings'; // @ts-ignore: No implicit any import { useDropdownList } from '../../hooks/useDropdownList'; +// @ts-ignore: No implicit any import { useMyMetadata } from '../../hooks/useMetadata'; import { useUnreadPollQuizPresent } from '../../hooks/useUnreadPollQuizPresent'; import { useLandscapeHLSStream, useMobileHLSStream } from '../../../common/hooks'; @@ -93,6 +95,8 @@ export const MwebOptions = ({ const peerCount = useHMSStore(selectPeerCount); const emojiCardRef = useRef(null); const { isBRBOn, toggleBRB, isHandRaised, toggleHandRaise } = useMyMetadata(); + const { toggleAudio, toggleVideo } = useAVToggle(); + const noAVPermissions = !(toggleAudio || toggleVideo); const { unreadPollQuiz, setUnreadPollQuiz } = useUnreadPollQuizPresent(); const { title, description } = useRoomLayoutHeader(); const toggleDetailsSheet = useSheetToggle(SHEET_OPTIONS.ROOM_DETAILS); @@ -171,7 +175,7 @@ export const MwebOptions = ({ )} - {elements.hand_raise ? ( + {!noAVPermissions ? ( { diff --git a/packages/roomkit-react/src/Prebuilt/components/PreviousRoleInMetadata.tsx b/packages/roomkit-react/src/Prebuilt/components/PreviousRoleInMetadata.tsx index c94fd0daa5..110aa7d7b4 100644 --- a/packages/roomkit-react/src/Prebuilt/components/PreviousRoleInMetadata.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/PreviousRoleInMetadata.tsx @@ -1,5 +1,6 @@ import { useEffect } from 'react'; import { selectLocalPeerRoleName, useHMSVanillaStore } from '@100mslive/react-sdk'; +// @ts-ignore: No implicit Any import { useMyMetadata } from './hooks/useMetadata'; export const PreviousRoleInMetadata = () => { diff --git a/packages/roomkit-react/src/Prebuilt/components/RaiseHand.tsx b/packages/roomkit-react/src/Prebuilt/components/RaiseHand.tsx index e3b61f45b1..c391e3fa20 100644 --- a/packages/roomkit-react/src/Prebuilt/components/RaiseHand.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/RaiseHand.tsx @@ -4,17 +4,11 @@ import { CSS } from '../../Theme'; import { Tooltip } from '../../Tooltip'; // @ts-ignore: No implicit Any import IconButton from '../IconButton'; -import { useRoomLayoutConferencingScreen } from '../provider/roomLayoutProvider/hooks/useRoomLayoutScreen'; +// @ts-ignore: No implicit Any import { useMyMetadata } from './hooks/useMetadata'; export const RaiseHand = ({ css }: { css?: CSS }) => { const { isHandRaised, toggleHandRaise } = useMyMetadata(); - const { elements } = useRoomLayoutConferencingScreen(); - - if (!elements.hand_raise) { - return null; - } - return ( { const metaData = useHMSStore(selectPeerMetadata(localPeerId)); const isHandRaised = useHMSStore(selectHasPeerHandRaised(localPeerId)); - const update = async (updatedFields: Record) => { + const update = async updatedFields => { try { // get current state from store and merge updated fields const currentMetadata = vanillaStore.getState(selectPeerMetadata(localPeerId)); @@ -24,7 +24,6 @@ export const useMyMetadata = () => { } catch (error) { console.error('failed to update metadata ', updatedFields); } - return false; }; const toggleHandRaise = useCallback(async () => { @@ -44,6 +43,12 @@ export const useMyMetadata = () => { } }, [metaData?.isBRBOn]); //eslint-disable-line + const setPrevRole = async role => { + await update({ + prevRole: role, + }); + }; + return { isHandRaised, isBRBOn: !!metaData?.isBRBOn, @@ -51,5 +56,6 @@ export const useMyMetadata = () => { updateMetaData: update, toggleHandRaise, toggleBRB, + setPrevRole, }; }; diff --git a/yarn.lock b/yarn.lock index 9e756353e5..e2e56f855e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7,10 +7,10 @@ resolved "https://registry.yarnpkg.com/@100mslive/hms-noise-cancellation/-/hms-noise-cancellation-0.0.0-alpha.5.tgz#8aff14eb7168cbf91a6d54ecb831f88dcda86266" integrity sha512-C44MLdFrS+4uzWuyauyKCnQ3kOT70jBsGdMXCdCPrK6OPRhZFuMYULYb7XP1NfJjslOcRdENarFqA0T+RNfmuQ== -"@100mslive/types-prebuilt@0.12.8": - version "0.12.8" - resolved "https://registry.yarnpkg.com/@100mslive/types-prebuilt/-/types-prebuilt-0.12.8.tgz#2fe9007eb14e66ad3ba687313c4254e2ed085629" - integrity sha512-W1ISh3Mk8/wkomeFiBte7HZLk1gJocnN5U0N8rzZ9WFdDlAW7q/hKgnh+X1/9QxVcv3USfuZyKotbZ7AXmvCiQ== +"@100mslive/types-prebuilt@0.12.7": + version "0.12.7" + resolved "https://registry.yarnpkg.com/@100mslive/types-prebuilt/-/types-prebuilt-0.12.7.tgz#66e26701964a8c7a0ab7df4787ac64ad8f8870f4" + integrity sha512-GsDJCZA74+wuBorERQbVA0isRUQduBZzkyzRfMhFA29ZDaVTManrnwamf9TrZvrFJRFTVhZ6lv05oUaauqJRjA== "@aashutoshrathi/word-wrap@^1.2.3": version "1.2.6" @@ -15781,7 +15781,16 @@ string-natural-compare@^3.0.1: resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4" integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw== -"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -15881,7 +15890,14 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -17178,7 +17194,7 @@ worker-timers@^7.0.40: worker-timers-broker "^6.0.95" worker-timers-worker "^7.0.59" -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -17196,6 +17212,15 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"