Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove resolution popup when recording started #1659

Merged
merged 1 commit into from
Aug 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ import {
import { AlertTriangleIcon, CrossIcon, RecordIcon } from '@100mslive/react-icons';
import { Box, Button, config as cssConfig, Flex, HorizontalDivider, Loading, Popover, Text, Tooltip } from '../../../';
import { Sheet } from '../../../Sheet';
import { ResolutionInput } from '../Streaming/ResolutionInput';
import { getResolution } from '../Streaming/RTMPStreaming';
import { ToastManager } from '../Toast/ToastManager';
import { AdditionalRoomState, getRecordingText } from './AdditionalRoomState';
import { useSetAppDataByKey } from '../AppData/useUISettings';
import { formatTime } from '../../common/utils';
import { APP_DATA, RTMP_RECORD_DEFAULT_RESOLUTION } from '../../common/constants';
import { APP_DATA } from '../../common/constants';

export const LiveStatus = () => {
const { isHLSRunning, isRTMPRunning } = useRecordingStreaming();
Expand Down Expand Up @@ -112,7 +110,6 @@ export const RecordingStatus = () => {

const StartRecording = () => {
const permissions = useHMSStore(selectPermissions);
const [resolution, setResolution] = useState(RTMP_RECORD_DEFAULT_RESOLUTION);
const [open, setOpen] = useState(false);
const [recordingStarted, setRecordingState] = useSetAppDataByKey(APP_DATA.recordingStarted);
const { isBrowserRecordingOn, isStreamingOn, isHLSRunning } = useRecordingStreaming();
Expand Down Expand Up @@ -161,62 +158,38 @@ const StartRecording = () => {
);
}
return (
<Popover.Root open={open} onOpenChange={setOpen}>
<Popover.Trigger asChild>
<Button
data-testid="start_recording"
variant="standard"
icon
disabled={recordingStarted || isStreamingOn}
onClick={() => setOpen(true)}
>
{recordingStarted ? <Loading size={24} color="currentColor" /> : <RecordIcon />}
<Text as="span" css={{ '@md': { display: 'none' }, color: 'currentColor' }}>
{recordingStarted ? 'Starting' : 'Start'} Recording
</Text>
</Button>
</Popover.Trigger>
<Popover.Content align="end" sideOffset={8} css={{ w: '$64' }}>
<ResolutionInput
testId="recording_resolution"
css={{ flexDirection: 'column', alignItems: 'start' }}
onResolutionChange={setResolution}
/>
<Button
data-testid="start_recording_confirm"
variant="primary"
icon
css={{ ml: 'auto' }}
type="submit"
disabled={recordingStarted || isStreamingOn}
onClick={async () => {
try {
setRecordingState(true);
await hmsActions.startRTMPOrRecording({
resolution: getResolution(resolution),
record: true,
});
} catch (error) {
if (error.message.includes('stream already running')) {
ToastManager.addToast({
title: 'Recording already running',
variant: 'error',
});
} else {
ToastManager.addToast({
title: error.message,
variant: 'error',
});
}
setRecordingState(false);
}
setOpen(false);
}}
>
Start
</Button>
</Popover.Content>
</Popover.Root>
<Button
data-testid="start_recording"
variant="standard"
icon
disabled={recordingStarted || isStreamingOn}
onClick={async () => {
try {
setRecordingState(true);
await hmsActions.startRTMPOrRecording({
record: true,
});
} catch (error) {
if (error.message.includes('stream already running')) {
ToastManager.addToast({
title: 'Recording already running',
variant: 'error',
});
} else {
ToastManager.addToast({
title: error.message,
variant: 'error',
});
}
setRecordingState(false);
}
}}
>
{recordingStarted ? <Loading size={24} color="currentColor" /> : <RecordIcon />}
<Text as="span" css={{ '@md': { display: 'none' }, color: 'currentColor' }}>
{recordingStarted ? 'Starting' : 'Start'} Recording
</Text>
</Button>
);
};

Expand Down