2022-08-28 21:25:49 -05:00
|
|
|
import { createContext, Dispatch, SetStateAction } from 'react'
|
|
|
|
|
2022-08-31 09:55:57 -05:00
|
|
|
import { AlertOptions } from 'models/shell'
|
2022-11-13 17:11:09 -06:00
|
|
|
import { AudioState, ScreenShareState, VideoState, Peer } from 'models/chat'
|
2022-08-31 09:55:57 -05:00
|
|
|
|
2022-08-28 21:25:49 -05:00
|
|
|
interface ShellContextProps {
|
2022-09-27 00:10:31 +11:00
|
|
|
tabHasFocus: boolean
|
2023-01-24 03:50:14 +00:00
|
|
|
showRoomControls: boolean
|
|
|
|
setShowRoomControls: Dispatch<SetStateAction<boolean>>
|
2022-08-31 09:55:57 -05: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-05 01:08:38 +11:00
|
|
|
isPeerListOpen: boolean
|
|
|
|
setIsPeerListOpen: Dispatch<SetStateAction<boolean>>
|
|
|
|
peerList: Peer[]
|
|
|
|
setPeerList: Dispatch<SetStateAction<Peer[]>>
|
2022-10-31 21:40:44 -05:00
|
|
|
audioState: AudioState
|
|
|
|
setAudioState: Dispatch<SetStateAction<AudioState>>
|
2022-11-06 13:36:15 -06:00
|
|
|
videoState: VideoState
|
|
|
|
setVideoState: Dispatch<SetStateAction<VideoState>>
|
2022-11-13 17:11:09 -06:00
|
|
|
screenState: ScreenShareState
|
|
|
|
setScreenState: Dispatch<SetStateAction<ScreenShareState>>
|
2023-02-26 18:26:53 -06:00
|
|
|
peerAudios: Record<string, HTMLAudioElement>
|
|
|
|
setPeerAudios: Dispatch<SetStateAction<Record<string, HTMLAudioElement>>>
|
2023-03-04 12:55:37 -06:00
|
|
|
customUsername: string
|
|
|
|
setCustomUsername: Dispatch<SetStateAction<string>>
|
2022-08-28 21:25:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export const ShellContext = createContext<ShellContextProps>({
|
2022-09-27 00:10:31 +11:00
|
|
|
tabHasFocus: true,
|
2023-01-24 03:50:14 +00:00
|
|
|
showRoomControls: false,
|
|
|
|
setShowRoomControls: () => {},
|
2022-08-31 09:55:57 -05:00
|
|
|
setTitle: () => {},
|
|
|
|
showAlert: () => {},
|
2023-01-08 20:37:30 +00:00
|
|
|
roomId: undefined,
|
|
|
|
setRoomId: () => {},
|
|
|
|
password: undefined,
|
|
|
|
setPassword: () => {},
|
2022-10-05 01:08:38 +11:00
|
|
|
isPeerListOpen: false,
|
|
|
|
setIsPeerListOpen: () => {},
|
|
|
|
peerList: [],
|
|
|
|
setPeerList: () => {},
|
2022-10-31 21:40:44 -05:00
|
|
|
audioState: AudioState.STOPPED,
|
|
|
|
setAudioState: () => {},
|
2022-11-06 13:36:15 -06:00
|
|
|
videoState: VideoState.STOPPED,
|
|
|
|
setVideoState: () => {},
|
2022-11-13 17:11:09 -06:00
|
|
|
screenState: ScreenShareState.NOT_SHARING,
|
|
|
|
setScreenState: () => {},
|
2023-02-26 18:26:53 -06:00
|
|
|
peerAudios: {},
|
|
|
|
setPeerAudios: () => {},
|
2023-03-04 12:55:37 -06:00
|
|
|
customUsername: '',
|
|
|
|
setCustomUsername: () => {},
|
2022-08-28 21:25:49 -05:00
|
|
|
})
|