Skip to content

Commit

Permalink
Update publish-alpha (#3373)
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 authored Nov 18, 2024
2 parents b9a15a4 + 9e526fb commit a8d0a17
Showing 1 changed file with 7 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useEffect, useRef, useState } from 'react';
import React, { useEffect, useRef } from 'react';
import { DefaultConferencingScreen_Elements } from '@100mslive/types-prebuilt';
import { v4 as uuid } from 'uuid';
import {
HMSRoomState,
selectAppData,
selectIsConnectedToRoom,
selectRoomState,
useAwayNotifications,
Expand Down Expand Up @@ -34,7 +33,7 @@ import {
// @ts-ignore: No implicit Any
import { useAuthToken, useSetAppDataByKey } from './AppData/useUISettings';
import { useLandscapeHLSStream, useMobileHLSStream } from '../common/hooks';
import { APP_DATA, isAndroid, isIOS, isIPadOS } from '../common/constants';
import { APP_DATA } from '../common/constants';

export const ConferenceScreen = () => {
const { userName, endpoints, onJoin: onJoinFunc } = useHMSPrebuiltContext();
Expand All @@ -43,13 +42,11 @@ export const ConferenceScreen = () => {
const roomState = useHMSStore(selectRoomState);
const isConnectedToRoom = useHMSStore(selectIsConnectedToRoom);
const hmsActions = useHMSActions();
const [hideControls, setHideControls] = useState(false);
const dropdownList = useHMSStore(selectAppData(APP_DATA.dropdownList));

const authTokenInAppData = useAuthToken();
const headerRef = useRef<HTMLDivElement | null>(null);
const footerRef = useRef<HTMLDivElement | null>(null);
const isMobileDevice = isAndroid || isIOS || isIPadOS;
const dropdownListRef = useRef<string[]>();

const [isHLSStarted] = useSetAppDataByKey(APP_DATA.hlsStarted);
const { requestPermission } = useAwayNotifications();

Expand All @@ -60,28 +57,6 @@ export const ConferenceScreen = () => {
const isLandscapeHLSStream = useLandscapeHLSStream();
const isMwebHLSStream = isMobileHLSStream || isLandscapeHLSStream;

const toggleControls = () => {
if (dropdownListRef.current?.length === 0 && isMobileDevice && !isMwebHLSStream) {
setHideControls(value => !value);
}
};

useEffect(() => {
let timeout: undefined | ReturnType<typeof setTimeout>;
dropdownListRef.current = dropdownList || [];
if (dropdownListRef.current && dropdownListRef.current.length === 0) {
clearTimeout(timeout);
timeout = setTimeout(() => {
if (dropdownListRef.current && dropdownListRef.current.length === 0) {
setHideControls(isMobileDevice);
}
}, 5000);
}
return () => {
clearTimeout(timeout);
};
}, [dropdownList, hideControls, isMobileDevice]);

useEffect(() => {
if (
authTokenInAppData &&
Expand Down Expand Up @@ -128,8 +103,6 @@ export const ConferenceScreen = () => {
return <FullPageProgress text={roomState === HMSRoomState.Connecting ? 'Joining...' : ''} />;
}

const hideControlsForStreaming = isMwebHLSStream ? true : hideControls;

return (
<>
{isHLSStarted ? (
Expand All @@ -144,7 +117,7 @@ export const ConferenceScreen = () => {
css={{
h: '$18',
transition: 'margin 0.3s ease-in-out',
marginTop: hideControlsForStreaming ? `-${headerRef.current?.clientHeight}px` : 'none',
marginTop: isMwebHLSStream ? `-${headerRef.current?.clientHeight}px` : 'none',
'@md': {
h: '$17',
},
Expand All @@ -170,13 +143,12 @@ export const ConferenceScreen = () => {
}}
id="conferencing"
data-testid="conferencing"
onClick={toggleControls}
>
{screenProps.elements ? (
<VideoStreamingSection
screenType={screenProps.screenType}
elements={screenProps.elements}
hideControls={hideControlsForStreaming}
hideControls={isMwebHLSStream}
/>
) : null}
</Box>
Expand All @@ -188,7 +160,7 @@ export const ConferenceScreen = () => {
maxHeight: '$24',
transition: 'margin 0.3s ease-in-out',
bg: '$background_dim',
marginBottom: hideControlsForStreaming ? `-${footerRef.current?.clientHeight}px` : undefined,
marginBottom: isMwebHLSStream ? `-${footerRef.current?.clientHeight}px` : undefined,
'@md': {
maxHeight: 'unset',
bg: screenProps.screenType === 'hls_live_streaming' ? 'transparent' : '$background_dim',
Expand Down

0 comments on commit a8d0a17

Please sign in to comment.