chitchatter/src/contexts/ShellContext.ts
2023-03-15 10:10:17 -05:00

57 lines
1.8 KiB
TypeScript

import { createContext, Dispatch, SetStateAction } from 'react'
import { AlertOptions } from 'models/shell'
import { AudioState, ScreenShareState, VideoState, Peer } from 'models/chat'
interface ShellContextProps {
tabHasFocus: boolean
showRoomControls: boolean
setShowRoomControls: Dispatch<SetStateAction<boolean>>
setTitle: Dispatch<SetStateAction<string>>
showAlert: (message: string, options?: AlertOptions) => void
roomId?: string
setRoomId: Dispatch<SetStateAction<string | undefined>>
password?: string
setPassword: Dispatch<SetStateAction<string | undefined>>
isPeerListOpen: boolean
setIsPeerListOpen: Dispatch<SetStateAction<boolean>>
peerList: Peer[]
setPeerList: Dispatch<SetStateAction<Peer[]>>
audioState: AudioState
setAudioState: Dispatch<SetStateAction<AudioState>>
videoState: VideoState
setVideoState: Dispatch<SetStateAction<VideoState>>
screenState: ScreenShareState
setScreenState: Dispatch<SetStateAction<ScreenShareState>>
peerAudios: Record<string, HTMLAudioElement>
setPeerAudios: Dispatch<SetStateAction<Record<string, HTMLAudioElement>>>
customUsername: string
setCustomUsername: Dispatch<SetStateAction<string>>
}
export const ShellContext = createContext<ShellContextProps>({
tabHasFocus: true,
showRoomControls: false,
setShowRoomControls: () => {},
setTitle: () => {},
showAlert: () => {},
roomId: undefined,
setRoomId: () => {},
password: undefined,
setPassword: () => {},
isPeerListOpen: false,
setIsPeerListOpen: () => {},
peerList: [],
setPeerList: () => {},
audioState: AudioState.STOPPED,
setAudioState: () => {},
videoState: VideoState.STOPPED,
setVideoState: () => {},
screenState: ScreenShareState.NOT_SHARING,
setScreenState: () => {},
peerAudios: {},
setPeerAudios: () => {},
customUsername: '',
setCustomUsername: () => {},
})