Skip to content

Commit a40c76b

Browse files
committed
✨(perf) hide main layout when pip is open
avoid rendering main video tiles while pip is active
1 parent e9684e0 commit a40c76b

1 file changed

Lines changed: 33 additions & 25 deletions

File tree

src/frontend/src/features/rooms/livekit/prefabs/VideoConference.tsx

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { useVideoResolutionSubscription } from '../hooks/useVideoResolutionSubsc
3535
import { SettingsDialogProvider } from '@/features/settings/components/SettingsDialogProvider'
3636
import { IsIdleDisconnectModal } from '../components/IsIdleDisconnectModal'
3737
import { RoomPiP } from '@/features/pip/components/RoomPiP'
38+
import { useRoomPiP } from '@/features/pip/hooks/useRoomPiP'
3839
import { getParticipantName } from '@/features/rooms/utils/getParticipantName'
3940
import { useScreenReaderAnnounce } from '@/hooks/useScreenReaderAnnounce'
4041
import { ReactionPortals } from '@/features/reactions/components/ReactionPortals'
@@ -228,6 +229,9 @@ export function VideoConference({ ...props }: VideoConferenceProps) {
228229
])
229230
/* eslint-enable react-hooks/exhaustive-deps */
230231

232+
const { isOpen: isPiPOpen } = useRoomPiP()
233+
const shouldRenderMainLayout = !isPiPOpen
234+
231235
const [isShareErrorVisible, setIsShareErrorVisible] = useState(false)
232236

233237
return (
@@ -249,32 +253,36 @@ export function VideoConference({ ...props }: VideoConferenceProps) {
249253
/>
250254
<IsIdleDisconnectModal />
251255
<RoomContentArea>
252-
{!focusTrack ? (
253-
<div
254-
className="lk-grid-layout-wrapper"
255-
style={{ height: 'auto' }}
256-
>
257-
<GridLayout tracks={tracks} style={{ padding: 0 }}>
258-
<ParticipantTile />
259-
</GridLayout>
260-
</div>
261-
) : (
262-
<div
263-
className="lk-focus-layout-wrapper"
264-
style={{ height: 'auto' }}
265-
>
266-
<FocusLayoutContainer style={{ padding: 0 }}>
267-
<CarouselLayout
268-
tracks={carouselTracks}
269-
style={{
270-
minWidth: '200px',
271-
}}
256+
{shouldRenderMainLayout && (
257+
<>
258+
{!focusTrack ? (
259+
<div
260+
className="lk-grid-layout-wrapper"
261+
style={{ height: 'auto' }}
262+
>
263+
<GridLayout tracks={tracks} style={{ padding: 0 }}>
264+
<ParticipantTile />
265+
</GridLayout>
266+
</div>
267+
) : (
268+
<div
269+
className="lk-focus-layout-wrapper"
270+
style={{ height: 'auto' }}
272271
>
273-
<ParticipantTile />
274-
</CarouselLayout>
275-
{focusTrack && <FocusLayout trackRef={focusTrack} />}
276-
</FocusLayoutContainer>
277-
</div>
272+
<FocusLayoutContainer style={{ padding: 0 }}>
273+
<CarouselLayout
274+
tracks={carouselTracks}
275+
style={{
276+
minWidth: '200px',
277+
}}
278+
>
279+
<ParticipantTile />
280+
</CarouselLayout>
281+
{focusTrack && <FocusLayout trackRef={focusTrack} />}
282+
</FocusLayoutContainer>
283+
</div>
284+
)}
285+
</>
278286
)}
279287
</RoomContentArea>
280288
<ControlBar

0 commit comments

Comments
 (0)