mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-31 04:37:57 +00:00
⚡️(frontend) narrow ParticipantToggle event subscriptions
Reduce the set of events the ParticipantToggle subscribes to, so it does not re-render on every LocalParticipant event but only on the ones that actually affect its rendering.
This commit is contained in:
+9
-3
@@ -3,10 +3,11 @@ import { RiGroupLine, RiInfinityLine } from '@remixicon/react'
|
|||||||
import { ToggleButton } from '@/primitives'
|
import { ToggleButton } from '@/primitives'
|
||||||
import { VisualOnlyTooltip } from '@/primitives/VisualOnlyTooltip'
|
import { VisualOnlyTooltip } from '@/primitives/VisualOnlyTooltip'
|
||||||
import { css } from '@/styled-system/css'
|
import { css } from '@/styled-system/css'
|
||||||
import { useParticipants } from '@livekit/components-react'
|
import { useRemoteParticipants } from '@livekit/components-react'
|
||||||
import { useSidePanel } from '../../../hooks/useSidePanel'
|
import { useSidePanel } from '../../../hooks/useSidePanel'
|
||||||
import { ToggleButtonProps } from '@/primitives/ToggleButton'
|
import { ToggleButtonProps } from '@/primitives/ToggleButton'
|
||||||
import { useRegisterKeyboardShortcut } from '@/features/shortcuts/useRegisterKeyboardShortcut'
|
import { useRegisterKeyboardShortcut } from '@/features/shortcuts/useRegisterKeyboardShortcut'
|
||||||
|
import { RoomEvent } from 'livekit-client'
|
||||||
|
|
||||||
export const ParticipantsToggle = ({
|
export const ParticipantsToggle = ({
|
||||||
onPress,
|
onPress,
|
||||||
@@ -19,8 +20,13 @@ export const ParticipantsToggle = ({
|
|||||||
* The 'numParticipant' property on the room only updates when the room's metadata changes,
|
* The 'numParticipant' property on the room only updates when the room's metadata changes,
|
||||||
* resulting in a delay compared to the participant list's actual refresh rate.
|
* resulting in a delay compared to the participant list's actual refresh rate.
|
||||||
*/
|
*/
|
||||||
const participants = useParticipants()
|
const remoteParticipants = useRemoteParticipants({
|
||||||
const numParticipants = participants?.length
|
updateOnlyOn: [
|
||||||
|
RoomEvent.ParticipantConnected,
|
||||||
|
RoomEvent.ParticipantDisconnected,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
const numParticipants = remoteParticipants?.length + 1 // for the local participant
|
||||||
const announcedCount =
|
const announcedCount =
|
||||||
numParticipants && numParticipants > 0 ? numParticipants : 1
|
numParticipants && numParticipants > 0 ? numParticipants : 1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user