forked from Shiloh/remnantchat
fix: prevent video focusing when there is only one video
This commit is contained in:
parent
f20f32f6a6
commit
97d5b64fc1
@ -38,31 +38,6 @@ export const RoomVideoDisplay = ({ userId }: RoomVideoDisplayProps) => {
|
|||||||
selfScreenStream,
|
selfScreenStream,
|
||||||
} = roomContext
|
} = roomContext
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!selectedPeerStream) return
|
|
||||||
|
|
||||||
const allMediaStreams = [
|
|
||||||
...Object.values(peerVideoStreams),
|
|
||||||
...Object.values(peerScreenStreams),
|
|
||||||
selfVideoStream,
|
|
||||||
selfScreenStream,
|
|
||||||
]
|
|
||||||
|
|
||||||
for (const mediaStream of allMediaStreams) {
|
|
||||||
if (mediaStream?.id === selectedPeerStream.videoStream.id) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setSelectedPeerStream(null)
|
|
||||||
}, [
|
|
||||||
peerScreenStreams,
|
|
||||||
peerVideoStreams,
|
|
||||||
selectedPeerStream,
|
|
||||||
selfScreenStream,
|
|
||||||
selfVideoStream,
|
|
||||||
])
|
|
||||||
|
|
||||||
const peersWithVideo: PeerWithVideo[] = peerList.reduce(
|
const peersWithVideo: PeerWithVideo[] = peerList.reduce(
|
||||||
(acc: PeerWithVideo[], peer: Peer) => {
|
(acc: PeerWithVideo[], peer: Peer) => {
|
||||||
const videoStream = peerVideoStreams[peer.peerId]
|
const videoStream = peerVideoStreams[peer.peerId]
|
||||||
@ -91,6 +66,37 @@ export const RoomVideoDisplay = ({ userId }: RoomVideoDisplayProps) => {
|
|||||||
return sum
|
return sum
|
||||||
}, 0)
|
}, 0)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!selectedPeerStream) return
|
||||||
|
|
||||||
|
if (numberOfVideos < 2) {
|
||||||
|
setSelectedPeerStream(null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const allMediaStreams = [
|
||||||
|
...Object.values(peerVideoStreams),
|
||||||
|
...Object.values(peerScreenStreams),
|
||||||
|
selfVideoStream,
|
||||||
|
selfScreenStream,
|
||||||
|
]
|
||||||
|
|
||||||
|
for (const mediaStream of allMediaStreams) {
|
||||||
|
if (mediaStream?.id === selectedPeerStream.videoStream.id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setSelectedPeerStream(null)
|
||||||
|
}, [
|
||||||
|
numberOfVideos,
|
||||||
|
peerScreenStreams,
|
||||||
|
peerVideoStreams,
|
||||||
|
selectedPeerStream,
|
||||||
|
selfScreenStream,
|
||||||
|
selfVideoStream,
|
||||||
|
])
|
||||||
|
|
||||||
const handleVideoClick = (
|
const handleVideoClick = (
|
||||||
peerId: string,
|
peerId: string,
|
||||||
videoStreamType: VideoStreamType,
|
videoStreamType: VideoStreamType,
|
||||||
@ -98,7 +104,7 @@ export const RoomVideoDisplay = ({ userId }: RoomVideoDisplayProps) => {
|
|||||||
) => {
|
) => {
|
||||||
if (selectedPeerStream?.videoStream === videoStream) {
|
if (selectedPeerStream?.videoStream === videoStream) {
|
||||||
setSelectedPeerStream(null)
|
setSelectedPeerStream(null)
|
||||||
} else {
|
} else if (numberOfVideos > 1) {
|
||||||
setSelectedPeerStream({ peerId, videoStreamType, videoStream })
|
setSelectedPeerStream({ peerId, videoStreamType, videoStream })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user