refactor: remove numberOfPeers state

This commit is contained in:
Jeremy Kahn 2023-03-15 09:51:49 -05:00 committed by Jeremy Kahn
parent d6f9b10ce2
commit 7ba62c030b
3 changed files with 0 additions and 18 deletions

View File

@ -52,8 +52,6 @@ export function useRoom(
) )
const { const {
numberOfPeers,
setNumberOfPeers,
peerList, peerList,
setPeerList, setPeerList,
tabHasFocus, tabHasFocus,
@ -279,9 +277,6 @@ export function useRoom(
showAlert(`Someone has joined the room`, { showAlert(`Someone has joined the room`, {
severity: 'success', severity: 'success',
}) })
const newNumberOfPeers = numberOfPeers + 1
setNumberOfPeers(newNumberOfPeers)
;(async () => { ;(async () => {
try { try {
const promises: Promise<any>[] = [ const promises: Promise<any>[] = [
@ -314,10 +309,6 @@ export function useRoom(
} }
) )
const newNumberOfPeers = numberOfPeers - 1
setNumberOfPeers(newNumberOfPeers)
setNumberOfPeers(newNumberOfPeers)
if (peerExist) { if (peerExist) {
const peerListClone = [...peerList] const peerListClone = [...peerList]
peerListClone.splice(peerIndex, 1) peerListClone.splice(peerIndex, 1)

View File

@ -61,7 +61,6 @@ export const Shell = ({ appNeedsUpdate, children, userPeerId }: ShellProps) => {
const [isFullscreen, setIsFullscreen] = useState(false) const [isFullscreen, setIsFullscreen] = useState(false)
const [title, setTitle] = useState('') const [title, setTitle] = useState('')
const [alertText, setAlertText] = useState('') const [alertText, setAlertText] = useState('')
const [numberOfPeers, setNumberOfPeers] = useState(1)
const [roomId, setRoomId] = useState<string | undefined>(undefined) const [roomId, setRoomId] = useState<string | undefined>(undefined)
const [password, setPassword] = useState<string | undefined>(undefined) const [password, setPassword] = useState<string | undefined>(undefined)
const [isPeerListOpen, setIsPeerListOpen] = useState(defaultSidebarsOpen) const [isPeerListOpen, setIsPeerListOpen] = useState(defaultSidebarsOpen)
@ -88,9 +87,7 @@ export const Shell = ({ appNeedsUpdate, children, userPeerId }: ShellProps) => {
const shellContextValue = useMemo( const shellContextValue = useMemo(
() => ({ () => ({
numberOfPeers,
tabHasFocus, tabHasFocus,
setNumberOfPeers,
showRoomControls, showRoomControls,
setShowRoomControls, setShowRoomControls,
setTitle, setTitle,
@ -122,10 +119,8 @@ export const Shell = ({ appNeedsUpdate, children, userPeerId }: ShellProps) => {
setRoomId, setRoomId,
password, password,
setPassword, setPassword,
numberOfPeers,
peerList, peerList,
tabHasFocus, tabHasFocus,
setNumberOfPeers,
showRoomControls, showRoomControls,
setShowRoomControls, setShowRoomControls,
setTitle, setTitle,

View File

@ -4,9 +4,7 @@ import { AlertOptions } from 'models/shell'
import { AudioState, ScreenShareState, VideoState, Peer } from 'models/chat' import { AudioState, ScreenShareState, VideoState, Peer } from 'models/chat'
interface ShellContextProps { interface ShellContextProps {
numberOfPeers: number
tabHasFocus: boolean tabHasFocus: boolean
setNumberOfPeers: Dispatch<SetStateAction<number>>
showRoomControls: boolean showRoomControls: boolean
setShowRoomControls: Dispatch<SetStateAction<boolean>> setShowRoomControls: Dispatch<SetStateAction<boolean>>
setTitle: Dispatch<SetStateAction<string>> setTitle: Dispatch<SetStateAction<string>>
@ -32,9 +30,7 @@ interface ShellContextProps {
} }
export const ShellContext = createContext<ShellContextProps>({ export const ShellContext = createContext<ShellContextProps>({
numberOfPeers: 1,
tabHasFocus: true, tabHasFocus: true,
setNumberOfPeers: () => {},
showRoomControls: false, showRoomControls: false,
setShowRoomControls: () => {}, setShowRoomControls: () => {},
setTitle: () => {}, setTitle: () => {},