diff --git a/src/components/Shell/EnvironmentUnsupportedDialog.tsx b/src/components/Shell/EnvironmentUnsupportedDialog.tsx new file mode 100644 index 0000000..c12cea6 --- /dev/null +++ b/src/components/Shell/EnvironmentUnsupportedDialog.tsx @@ -0,0 +1,79 @@ +import Box from '@mui/material/Box' +import Dialog from '@mui/material/Dialog' +import DialogContent from '@mui/material/DialogContent' +import DialogContentText from '@mui/material/DialogContentText' +import DialogTitle from '@mui/material/DialogTitle' +import ErrorIcon from '@mui/icons-material/Error' +import Typography from '@mui/material/Typography' +import useTheme from '@mui/material/styles/useTheme' +import Link from '@mui/material/Link' + +const { isSecureContext, RTCDataChannel } = window +const doesSupportWebRtc = RTCDataChannel !== undefined + +export const isEnvironmentSupported = + (isSecureContext && doesSupportWebRtc) || process.env.NODE_ENV === 'test' + +export const EnvironmentUnsupportedDialog = () => { + const theme = useTheme() + + return ( + + + + ({ + color: theme.palette.error.main, + mr: theme.spacing(1), + })} + /> + Environment unsupported + + + + + Chitchatter is unable to start up. The following issues were detected: + + + {!isSecureContext ? ( +
  • + The app is not being served from a{' '} + + secure context + + . +
  • + ) : null} + {!doesSupportWebRtc ? ( +
  • + Your browser does not support WebRTC. Consider using{' '} + + a browser that does + + . +
  • + ) : null} +
    +
    +
    + ) +} diff --git a/src/components/Shell/Shell.tsx b/src/components/Shell/Shell.tsx index 46bc5de..a9070d9 100644 --- a/src/components/Shell/Shell.tsx +++ b/src/components/Shell/Shell.tsx @@ -31,6 +31,10 @@ import { QRCodeDialog } from './QRCodeDialog' import { RoomShareDialog } from './RoomShareDialog' import { useConnectionTest } from './useConnectionTest' import { ServerConnectionFailureDialog } from './ServerConnectionFailureDialog' +import { + EnvironmentUnsupportedDialog, + isEnvironmentSupported, +} from './EnvironmentUnsupportedDialog' export interface ShellProps extends PropsWithChildren { userPeerId: string @@ -309,70 +313,78 @@ export const Shell = ({ appNeedsUpdate, children, userPeerId }: ShellProps) => { - - - - setShowRoomControls(!showRoomControls)} - setIsQRCodeDialogOpen={setIsQRCodeDialogOpen} - showAppBar={showAppBar} - isFullscreen={isFullscreen} - setIsFullscreen={setIsFullscreen} - /> - - - {children} - - - - - - + {isEnvironmentSupported ? ( + <> + + + + + setShowRoomControls(!showRoomControls) + } + setIsQRCodeDialogOpen={setIsQRCodeDialogOpen} + showAppBar={showAppBar} + isFullscreen={isFullscreen} + setIsFullscreen={setIsFullscreen} + /> + + + {children} + + + + + + + + ) : ( + + )} )