2022-08-29 02:25:49 +00:00
|
|
|
import { createContext, Dispatch, SetStateAction } from 'react'
|
|
|
|
|
2022-08-31 14:55:57 +00:00
|
|
|
import { AlertOptions } from 'models/shell'
|
2022-11-13 23:11:09 +00:00
|
|
|
import { AudioState, ScreenShareState, VideoState, Peer } from 'models/chat'
|
2023-03-25 19:40:07 +00:00
|
|
|
import { PeerConnectionType } from 'services/PeerRoom/PeerRoom'
|
2023-03-28 02:51:33 +00:00
|
|
|
import { ConnectionTestResults } from 'components/Shell/useConnectionTest'
|
2022-08-31 14:55:57 +00:00
|
|
|
|
2022-08-29 02:25:49 +00:00
|
|
|
interface ShellContextProps {
|
2022-09-26 13:10:31 +00:00
|
|
|
tabHasFocus: boolean
|
2023-01-24 03:50:14 +00:00
|
|
|
showRoomControls: boolean
|
|
|
|
setShowRoomControls: Dispatch<SetStateAction<boolean>>
|
2022-08-31 14:55:57 +00:00
|
|
|
setTitle: Dispatch<SetStateAction<string>>
|
|
|
|
showAlert: (message: string, options?: AlertOptions) => void
|
2023-01-08 20:37:30 +00:00
|
|
|
roomId?: string
|
|
|
|
setRoomId: Dispatch<SetStateAction<string | undefined>>
|
|
|
|
password?: string
|
|
|
|
setPassword: Dispatch<SetStateAction<string | undefined>>
|
2022-10-04 14:08:38 +00:00
|
|
|
isPeerListOpen: boolean
|
|
|
|
setIsPeerListOpen: Dispatch<SetStateAction<boolean>>
|
|
|
|
peerList: Peer[]
|
|
|
|
setPeerList: Dispatch<SetStateAction<Peer[]>>
|
2023-03-25 19:40:07 +00:00
|
|
|
peerConnectionTypes: Record<string, PeerConnectionType>
|
|
|
|
setPeerConnectionTypes: Dispatch<
|
|
|
|
SetStateAction<Record<string, PeerConnectionType>>
|
|
|
|
>
|
2022-11-01 02:40:44 +00:00
|
|
|
audioState: AudioState
|
|
|
|
setAudioState: Dispatch<SetStateAction<AudioState>>
|
2022-11-06 19:36:15 +00:00
|
|
|
videoState: VideoState
|
|
|
|
setVideoState: Dispatch<SetStateAction<VideoState>>
|
2022-11-13 23:11:09 +00:00
|
|
|
screenState: ScreenShareState
|
|
|
|
setScreenState: Dispatch<SetStateAction<ScreenShareState>>
|
2023-02-27 00:26:53 +00:00
|
|
|
peerAudios: Record<string, HTMLAudioElement>
|
|
|
|
setPeerAudios: Dispatch<SetStateAction<Record<string, HTMLAudioElement>>>
|
2023-03-04 18:55:37 +00:00
|
|
|
customUsername: string
|
|
|
|
setCustomUsername: Dispatch<SetStateAction<string>>
|
2023-03-28 02:51:33 +00:00
|
|
|
connectionTestResults: ConnectionTestResults
|
2022-08-29 02:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const ShellContext = createContext<ShellContextProps>({
|
2022-09-26 13:10:31 +00:00
|
|
|
tabHasFocus: true,
|
2023-01-24 03:50:14 +00:00
|
|
|
showRoomControls: false,
|
|
|
|
setShowRoomControls: () => {},
|
2022-08-31 14:55:57 +00:00
|
|
|
setTitle: () => {},
|
|
|
|
showAlert: () => {},
|
2023-01-08 20:37:30 +00:00
|
|
|
roomId: undefined,
|
|
|
|
setRoomId: () => {},
|
|
|
|
password: undefined,
|
|
|
|
setPassword: () => {},
|
2022-10-04 14:08:38 +00:00
|
|
|
isPeerListOpen: false,
|
|
|
|
setIsPeerListOpen: () => {},
|
|
|
|
peerList: [],
|
|
|
|
setPeerList: () => {},
|
2023-03-25 19:40:07 +00:00
|
|
|
peerConnectionTypes: {},
|
|
|
|
setPeerConnectionTypes: () => {},
|
2022-11-01 02:40:44 +00:00
|
|
|
audioState: AudioState.STOPPED,
|
|
|
|
setAudioState: () => {},
|
2022-11-06 19:36:15 +00:00
|
|
|
videoState: VideoState.STOPPED,
|
|
|
|
setVideoState: () => {},
|
2022-11-13 23:11:09 +00:00
|
|
|
screenState: ScreenShareState.NOT_SHARING,
|
|
|
|
setScreenState: () => {},
|
2023-02-27 00:26:53 +00:00
|
|
|
peerAudios: {},
|
|
|
|
setPeerAudios: () => {},
|
2023-03-04 18:55:37 +00:00
|
|
|
customUsername: '',
|
|
|
|
setCustomUsername: () => {},
|
2023-07-13 14:50:54 +00:00
|
|
|
connectionTestResults: { hasHost: false, hasRelay: false, hasTracker: false },
|
2022-08-29 02:25:49 +00:00
|
|
|
})
|