forked from Shiloh/remnantchat
* feat(connection-test): [closes #127] explain tracker connection problems
This commit is contained in:
parent
f67dbb60d3
commit
9b9d294f98
@ -1,3 +1,4 @@
|
|||||||
|
import { useContext } from 'react'
|
||||||
import CircularProgress from '@mui/material/CircularProgress'
|
import CircularProgress from '@mui/material/CircularProgress'
|
||||||
import Tooltip from '@mui/material/Tooltip'
|
import Tooltip from '@mui/material/Tooltip'
|
||||||
import Typography from '@mui/material/Typography'
|
import Typography from '@mui/material/Typography'
|
||||||
@ -6,6 +7,7 @@ import { Box } from '@mui/system'
|
|||||||
import ReportIcon from '@mui/icons-material/Report'
|
import ReportIcon from '@mui/icons-material/Report'
|
||||||
|
|
||||||
import { TrackerConnection } from 'services/ConnectionTest/ConnectionTest'
|
import { TrackerConnection } from 'services/ConnectionTest/ConnectionTest'
|
||||||
|
import { ShellContext } from 'contexts/ShellContext'
|
||||||
|
|
||||||
import { ConnectionTestResults as IConnectionTestResults } from './useConnectionTest'
|
import { ConnectionTestResults as IConnectionTestResults } from './useConnectionTest'
|
||||||
|
|
||||||
@ -15,9 +17,19 @@ interface ConnectionTestResultsProps {
|
|||||||
export const ConnectionTestResults = ({
|
export const ConnectionTestResults = ({
|
||||||
connectionTestResults: { hasHost, hasRelay, trackerConnection },
|
connectionTestResults: { hasHost, hasRelay, trackerConnection },
|
||||||
}: ConnectionTestResultsProps) => {
|
}: ConnectionTestResultsProps) => {
|
||||||
|
const { setIsServerConnectionFailureDialogOpen } = useContext(ShellContext)
|
||||||
|
|
||||||
|
const handleServerConnectionFailedMessageClick = () => {
|
||||||
|
setIsServerConnectionFailureDialogOpen(true)
|
||||||
|
}
|
||||||
|
|
||||||
if (trackerConnection === TrackerConnection.FAILED) {
|
if (trackerConnection === TrackerConnection.FAILED) {
|
||||||
return (
|
return (
|
||||||
<Typography variant="subtitle2">
|
<Typography
|
||||||
|
variant="subtitle2"
|
||||||
|
sx={{ cursor: 'pointer' }}
|
||||||
|
onClick={handleServerConnectionFailedMessageClick}
|
||||||
|
>
|
||||||
<Box
|
<Box
|
||||||
sx={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}
|
sx={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}
|
||||||
>
|
>
|
||||||
|
65
src/components/Shell/ServerConnectionFailureDialog.tsx
Normal file
65
src/components/Shell/ServerConnectionFailureDialog.tsx
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import { useContext } from 'react'
|
||||||
|
import useTheme from '@mui/material/styles/useTheme'
|
||||||
|
import Typography from '@mui/material/Typography'
|
||||||
|
import Box from '@mui/material/Box'
|
||||||
|
import Button from '@mui/material/Button'
|
||||||
|
import Dialog from '@mui/material/Dialog'
|
||||||
|
import DialogActions from '@mui/material/DialogActions'
|
||||||
|
import DialogContent from '@mui/material/DialogContent'
|
||||||
|
import DialogContentText from '@mui/material/DialogContentText'
|
||||||
|
import DialogTitle from '@mui/material/DialogTitle'
|
||||||
|
import ReportIcon from '@mui/icons-material/Report'
|
||||||
|
|
||||||
|
import { ShellContext } from 'contexts/ShellContext'
|
||||||
|
|
||||||
|
export const ServerConnectionFailureDialog = () => {
|
||||||
|
const theme = useTheme()
|
||||||
|
const {
|
||||||
|
isServerConnectionFailureDialogOpen,
|
||||||
|
setIsServerConnectionFailureDialogOpen,
|
||||||
|
} = useContext(ShellContext)
|
||||||
|
|
||||||
|
const handleDialogClose = () => {
|
||||||
|
setIsServerConnectionFailureDialogOpen(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
open={isServerConnectionFailureDialogOpen}
|
||||||
|
onClose={handleDialogClose}
|
||||||
|
>
|
||||||
|
<DialogTitle>
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center' }}>
|
||||||
|
<ReportIcon
|
||||||
|
fontSize="medium"
|
||||||
|
sx={theme => ({
|
||||||
|
color: theme.palette.error.main,
|
||||||
|
mr: theme.spacing(1),
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
Server connection failed
|
||||||
|
</Box>
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogContentText>
|
||||||
|
A pairing server could not be found. Make sure you are connected to
|
||||||
|
the internet. If you still can't connect, try:
|
||||||
|
</DialogContentText>
|
||||||
|
<Typography
|
||||||
|
component="ul"
|
||||||
|
sx={{
|
||||||
|
color: theme.palette.text.secondary,
|
||||||
|
m: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<li>Refreshing the page</li>
|
||||||
|
<li>Disabling any adblockers</li>
|
||||||
|
<li>Connecting to a different network</li>
|
||||||
|
</Typography>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button onClick={handleDialogClose}>Close</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
@ -30,6 +30,7 @@ import { PeerList } from './PeerList'
|
|||||||
import { QRCodeDialog } from './QRCodeDialog'
|
import { QRCodeDialog } from './QRCodeDialog'
|
||||||
import { RoomShareDialog } from './RoomShareDialog'
|
import { RoomShareDialog } from './RoomShareDialog'
|
||||||
import { useConnectionTest } from './useConnectionTest'
|
import { useConnectionTest } from './useConnectionTest'
|
||||||
|
import { ServerConnectionFailureDialog } from './ServerConnectionFailureDialog'
|
||||||
|
|
||||||
export interface ShellProps extends PropsWithChildren {
|
export interface ShellProps extends PropsWithChildren {
|
||||||
userPeerId: string
|
userPeerId: string
|
||||||
@ -68,6 +69,10 @@ export const Shell = ({ appNeedsUpdate, children, userPeerId }: ShellProps) => {
|
|||||||
const [password, setPassword] = useState<string | undefined>(undefined)
|
const [password, setPassword] = useState<string | undefined>(undefined)
|
||||||
const [isPeerListOpen, setIsPeerListOpen] = useState(defaultSidebarsOpen)
|
const [isPeerListOpen, setIsPeerListOpen] = useState(defaultSidebarsOpen)
|
||||||
const [peerList, setPeerList] = useState<Peer[]>([]) // except self
|
const [peerList, setPeerList] = useState<Peer[]>([]) // except self
|
||||||
|
const [
|
||||||
|
isServerConnectionFailureDialogOpen,
|
||||||
|
setIsServerConnectionFailureDialogOpen,
|
||||||
|
] = useState(false)
|
||||||
const [peerConnectionTypes, setPeerConnectionTypes] = useState<
|
const [peerConnectionTypes, setPeerConnectionTypes] = useState<
|
||||||
Record<string, PeerConnectionType>
|
Record<string, PeerConnectionType>
|
||||||
>({})
|
>({})
|
||||||
@ -109,6 +114,8 @@ export const Shell = ({ appNeedsUpdate, children, userPeerId }: ShellProps) => {
|
|||||||
setIsPeerListOpen,
|
setIsPeerListOpen,
|
||||||
peerList,
|
peerList,
|
||||||
setPeerList,
|
setPeerList,
|
||||||
|
isServerConnectionFailureDialogOpen,
|
||||||
|
setIsServerConnectionFailureDialogOpen,
|
||||||
peerConnectionTypes,
|
peerConnectionTypes,
|
||||||
setPeerConnectionTypes,
|
setPeerConnectionTypes,
|
||||||
audioState,
|
audioState,
|
||||||
@ -131,6 +138,8 @@ export const Shell = ({ appNeedsUpdate, children, userPeerId }: ShellProps) => {
|
|||||||
password,
|
password,
|
||||||
setPassword,
|
setPassword,
|
||||||
peerList,
|
peerList,
|
||||||
|
isServerConnectionFailureDialogOpen,
|
||||||
|
setIsServerConnectionFailureDialogOpen,
|
||||||
peerConnectionTypes,
|
peerConnectionTypes,
|
||||||
tabHasFocus,
|
tabHasFocus,
|
||||||
showRoomControls,
|
showRoomControls,
|
||||||
@ -346,6 +355,7 @@ export const Shell = ({ appNeedsUpdate, children, userPeerId }: ShellProps) => {
|
|||||||
showAlert={showAlert}
|
showAlert={showAlert}
|
||||||
copyToClipboard={copyToClipboard}
|
copyToClipboard={copyToClipboard}
|
||||||
/>
|
/>
|
||||||
|
<ServerConnectionFailureDialog />
|
||||||
</Box>
|
</Box>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</ShellContext.Provider>
|
</ShellContext.Provider>
|
||||||
|
@ -20,6 +20,8 @@ interface ShellContextProps {
|
|||||||
setIsPeerListOpen: Dispatch<SetStateAction<boolean>>
|
setIsPeerListOpen: Dispatch<SetStateAction<boolean>>
|
||||||
peerList: Peer[]
|
peerList: Peer[]
|
||||||
setPeerList: Dispatch<SetStateAction<Peer[]>>
|
setPeerList: Dispatch<SetStateAction<Peer[]>>
|
||||||
|
isServerConnectionFailureDialogOpen: boolean
|
||||||
|
setIsServerConnectionFailureDialogOpen: Dispatch<SetStateAction<boolean>>
|
||||||
peerConnectionTypes: Record<string, PeerConnectionType>
|
peerConnectionTypes: Record<string, PeerConnectionType>
|
||||||
setPeerConnectionTypes: Dispatch<
|
setPeerConnectionTypes: Dispatch<
|
||||||
SetStateAction<Record<string, PeerConnectionType>>
|
SetStateAction<Record<string, PeerConnectionType>>
|
||||||
@ -51,6 +53,8 @@ export const ShellContext = createContext<ShellContextProps>({
|
|||||||
setIsPeerListOpen: () => {},
|
setIsPeerListOpen: () => {},
|
||||||
peerList: [],
|
peerList: [],
|
||||||
setPeerList: () => {},
|
setPeerList: () => {},
|
||||||
|
isServerConnectionFailureDialogOpen: false,
|
||||||
|
setIsServerConnectionFailureDialogOpen: () => {},
|
||||||
peerConnectionTypes: {},
|
peerConnectionTypes: {},
|
||||||
setPeerConnectionTypes: () => {},
|
setPeerConnectionTypes: () => {},
|
||||||
audioState: AudioState.STOPPED,
|
audioState: AudioState.STOPPED,
|
||||||
|
Loading…
Reference in New Issue
Block a user