refactor: remove numberOfPeers state
This commit is contained in:
parent
d6f9b10ce2
commit
7ba62c030b
@ -52,8 +52,6 @@ export function useRoom(
|
||||
)
|
||||
|
||||
const {
|
||||
numberOfPeers,
|
||||
setNumberOfPeers,
|
||||
peerList,
|
||||
setPeerList,
|
||||
tabHasFocus,
|
||||
@ -279,9 +277,6 @@ export function useRoom(
|
||||
showAlert(`Someone has joined the room`, {
|
||||
severity: 'success',
|
||||
})
|
||||
|
||||
const newNumberOfPeers = numberOfPeers + 1
|
||||
setNumberOfPeers(newNumberOfPeers)
|
||||
;(async () => {
|
||||
try {
|
||||
const promises: Promise<any>[] = [
|
||||
@ -314,10 +309,6 @@ export function useRoom(
|
||||
}
|
||||
)
|
||||
|
||||
const newNumberOfPeers = numberOfPeers - 1
|
||||
setNumberOfPeers(newNumberOfPeers)
|
||||
setNumberOfPeers(newNumberOfPeers)
|
||||
|
||||
if (peerExist) {
|
||||
const peerListClone = [...peerList]
|
||||
peerListClone.splice(peerIndex, 1)
|
||||
|
@ -61,7 +61,6 @@ export const Shell = ({ appNeedsUpdate, children, userPeerId }: ShellProps) => {
|
||||
const [isFullscreen, setIsFullscreen] = useState(false)
|
||||
const [title, setTitle] = useState('')
|
||||
const [alertText, setAlertText] = useState('')
|
||||
const [numberOfPeers, setNumberOfPeers] = useState(1)
|
||||
const [roomId, setRoomId] = useState<string | undefined>(undefined)
|
||||
const [password, setPassword] = useState<string | undefined>(undefined)
|
||||
const [isPeerListOpen, setIsPeerListOpen] = useState(defaultSidebarsOpen)
|
||||
@ -88,9 +87,7 @@ export const Shell = ({ appNeedsUpdate, children, userPeerId }: ShellProps) => {
|
||||
|
||||
const shellContextValue = useMemo(
|
||||
() => ({
|
||||
numberOfPeers,
|
||||
tabHasFocus,
|
||||
setNumberOfPeers,
|
||||
showRoomControls,
|
||||
setShowRoomControls,
|
||||
setTitle,
|
||||
@ -122,10 +119,8 @@ export const Shell = ({ appNeedsUpdate, children, userPeerId }: ShellProps) => {
|
||||
setRoomId,
|
||||
password,
|
||||
setPassword,
|
||||
numberOfPeers,
|
||||
peerList,
|
||||
tabHasFocus,
|
||||
setNumberOfPeers,
|
||||
showRoomControls,
|
||||
setShowRoomControls,
|
||||
setTitle,
|
||||
|
@ -4,9 +4,7 @@ import { AlertOptions } from 'models/shell'
|
||||
import { AudioState, ScreenShareState, VideoState, Peer } from 'models/chat'
|
||||
|
||||
interface ShellContextProps {
|
||||
numberOfPeers: number
|
||||
tabHasFocus: boolean
|
||||
setNumberOfPeers: Dispatch<SetStateAction<number>>
|
||||
showRoomControls: boolean
|
||||
setShowRoomControls: Dispatch<SetStateAction<boolean>>
|
||||
setTitle: Dispatch<SetStateAction<string>>
|
||||
@ -32,9 +30,7 @@ interface ShellContextProps {
|
||||
}
|
||||
|
||||
export const ShellContext = createContext<ShellContextProps>({
|
||||
numberOfPeers: 1,
|
||||
tabHasFocus: true,
|
||||
setNumberOfPeers: () => {},
|
||||
showRoomControls: false,
|
||||
setShowRoomControls: () => {},
|
||||
setTitle: () => {},
|
||||
|
Loading…
Reference in New Issue
Block a user