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: show end session if endRoom permission exists #1905

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
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 @@ -16,17 +16,19 @@ import { useDropdownList } from '../hooks/useDropdownList';
export const DesktopLeaveRoom = ({
leaveRoom,
screenType,
endRoom,
}: {
leaveRoom: (args: { endstream: boolean }) => void;
screenType: keyof ConferencingScreen;
endRoom: () => void;
}) => {
const [open, setOpen] = useState(false);
const [showLeaveRoomAlert, setShowLeaveRoomAlert] = useState(false);
const [showEndStreamAlert, setShowEndStreamAlert] = useState(false);
const isConnected = useHMSStore(selectIsConnectedToRoom);
const permissions = useHMSStore(selectPermissions);
const { isStreamingOn } = useRecordingStreaming();
const showStream = permissions?.hlsStreaming && isStreamingOn;
const showStream = screenType !== 'hls_live_streaming' && isStreamingOn;

useDropdownList({ open: open || showEndStreamAlert || showLeaveRoomAlert, name: 'LeaveRoom' });

Expand All @@ -36,7 +38,7 @@ export const DesktopLeaveRoom = ({

return (
<Fragment>
{permissions.hlsStreaming ? (
{screenType !== 'hls_live_streaming' && (permissions?.hlsStreaming || permissions?.endRoom) ? (
<Flex>
<LeaveIconButton
key="LeaveRoom"
Expand All @@ -46,11 +48,7 @@ export const DesktopLeaveRoom = ({
borderBottomRightRadius: 0,
}}
onClick={() => {
if (screenType === 'hls_live_streaming') {
setShowLeaveRoomAlert(true);
} else {
leaveRoom({ endstream: false });
}
leaveRoom({ endstream: false });
}}
>
<Tooltip title="Leave Room">
Expand Down Expand Up @@ -94,7 +92,7 @@ export const DesktopLeaveRoom = ({
css={{ p: 0 }}
/>
</Dropdown.Item>
{isStreamingOn && permissions?.hlsStreaming ? (
{permissions?.endRoom || permissions?.hlsStreaming ? (
<Dropdown.Item
css={{
bg: '$alert_error_dim',
Expand Down Expand Up @@ -148,7 +146,7 @@ export const DesktopLeaveRoom = ({
<Dialog.Content css={{ w: 'min(420px, 90%)', p: '$8', bg: '$surface_dim' }}>
<EndSessionContent
setShowEndStreamAlert={setShowEndStreamAlert}
leaveRoom={leaveRoom}
leaveRoom={isStreamingOn ? leaveRoom : endRoom}
isStreamingOn={isStreamingOn}
isModal
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export const LeaveRoom = ({ screenType }: { screenType: keyof ConferencingScreen
ToastManager.addToast({ title: 'Error in stopping the stream', type: 'error' });
}
};
const endRoom = () => {
hmsActions.endRoom(false, 'End Room');
redirectToLeave();
};

const leaveRoom = async ({ endstream = false }) => {
if (endstream || (hlsState.running && peersWithStreamingRights.length === 1)) {
Expand All @@ -59,8 +63,8 @@ export const LeaveRoom = ({ screenType }: { screenType: keyof ConferencingScreen
return null;
}
return isMobile ? (
<MwebLeaveRoom leaveRoom={leaveRoom} screenType={screenType} />
<MwebLeaveRoom leaveRoom={leaveRoom} screenType={screenType} endRoom={endRoom} />
) : (
<DesktopLeaveRoom leaveRoom={leaveRoom} screenType={screenType} />
<DesktopLeaveRoom leaveRoom={leaveRoom} screenType={screenType} endRoom={endRoom} />
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@ import { useDropdownList } from '../hooks/useDropdownList';
export const MwebLeaveRoom = ({
leaveRoom,
screenType,
endRoom,
}: {
leaveRoom: (args: { endstream: boolean }) => void;
screenType: keyof ConferencingScreen;
endRoom: () => void;
}) => {
const [open, setOpen] = useState(false);
const [showLeaveRoomAlert, setShowLeaveRoomAlert] = useState(false);
const [showEndStreamAlert, setShowEndStreamAlert] = useState(false);
const isConnected = useHMSStore(selectIsConnectedToRoom);
const permissions = useHMSStore(selectPermissions);
const { isStreamingOn } = useRecordingStreaming();
const showStream = screenType !== 'hls_live_streaming' && isStreamingOn;

const showStream = permissions?.hlsStreaming && isStreamingOn;
useDropdownList({ open, name: 'LeaveRoom' });

if (!permissions || !isConnected) {
Expand All @@ -37,7 +39,7 @@ export const MwebLeaveRoom = ({

return (
<Fragment>
{permissions?.hlsStreaming ? (
{screenType !== 'hls_live_streaming' ? (
<Sheet.Root open={open} onOpenChange={setOpen}>
<Sheet.Trigger asChild>
<LeaveIconButton
Expand Down Expand Up @@ -67,7 +69,8 @@ export const MwebLeaveRoom = ({
onClick={() => leaveRoom({ endstream: false })}
css={{ pt: 0, mt: '$10', color: '$on_surface_low', '&:hover': { color: '$on_surface_high' } }}
/>
{isStreamingOn && permissions?.hlsStreaming ? (

{permissions?.endRoom || permissions?.hlsStreaming ? (
<LeaveCard
title={showStream ? 'End Stream' : 'End Session'}
subtitle={`The will end the ${
Expand Down Expand Up @@ -108,7 +111,7 @@ export const MwebLeaveRoom = ({
<Sheet.Content css={{ bg: '$surface_dim', p: '$10', pb: '$12' }}>
<EndSessionContent
setShowEndStreamAlert={setShowEndStreamAlert}
leaveRoom={leaveRoom}
leaveRoom={isStreamingOn ? leaveRoom : endRoom}
isStreamingOn={isStreamingOn}
/>
</Sheet.Content>
Expand Down
Loading