♻️(frontend) harmonize participant name handling in ParticipantTile

Align how the participant name is retrieved and rendered inside the
ParticipantTile, so the different code paths use a single consistent
approach instead of a mix of ad hoc logic.
This commit is contained in:
lebaudantoine
2026-07-23 18:56:16 +02:00
parent c3f212bf54
commit 8a24502295
2 changed files with 11 additions and 9 deletions
@@ -3,7 +3,6 @@ import {
LockLockedIcon, LockLockedIcon,
ScreenShareIcon, ScreenShareIcon,
useIsEncrypted, useIsEncrypted,
useParticipantInfo,
} from '@livekit/components-react' } from '@livekit/components-react'
import { HStack } from '@/styled-system/jsx' import { HStack } from '@/styled-system/jsx'
import { Participant } from 'livekit-client' import { Participant } from 'livekit-client'
@@ -12,13 +11,14 @@ import { ParticipantName } from './ParticipantName'
import { RaisedHandMetadataWrapper } from './RaisedHandMetadataWrapper' import { RaisedHandMetadataWrapper } from './RaisedHandMetadataWrapper'
export const ParticipantMetadata = ({ export const ParticipantMetadata = ({
displayedName,
participant, participant,
isScreenShare, isScreenShare,
}: { }: {
displayedName: string
participant: Participant participant: Participant
isScreenShare: boolean isScreenShare: boolean
}) => { }) => {
const { identity, name } = useParticipantInfo({ participant })
const isEncrypted = useIsEncrypted(participant) const isEncrypted = useIsEncrypted(participant)
return ( return (
@@ -42,7 +42,7 @@ export const ParticipantMetadata = ({
)} )}
<div className="lk-participant-name-wrapper"> <div className="lk-participant-name-wrapper">
<ParticipantName <ParticipantName
displayedName={name != '' ? name : identity} displayedName={displayedName}
isScreenShare={isScreenShare} isScreenShare={isScreenShare}
/> />
</div> </div>
@@ -9,6 +9,7 @@ import {
VideoTrack, VideoTrack,
TrackRefContext, TrackRefContext,
ParticipantContextIfNeeded, ParticipantContextIfNeeded,
useParticipantInfo,
} from '@livekit/components-react' } from '@livekit/components-react'
import { import {
isEqualTrackRef, isEqualTrackRef,
@@ -19,7 +20,6 @@ import { Track } from 'livekit-client'
import { ParticipantPlaceholder } from './ParticipantPlaceholder' import { ParticipantPlaceholder } from './ParticipantPlaceholder'
import { ParticipantTileFocus } from './ParticipantTileFocus' import { ParticipantTileFocus } from './ParticipantTileFocus'
import { FullScreenShareWarning } from './FullScreenShareWarning' import { FullScreenShareWarning } from './FullScreenShareWarning'
import { getParticipantName } from '@/features/rooms/utils/getParticipantName'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { getShortcutDescriptorById } from '@/features/shortcuts/catalog' import { getShortcutDescriptorById } from '@/features/shortcuts/catalog'
import { formatShortcutLabel } from '@/features/shortcuts/formatLabels' import { formatShortcutLabel } from '@/features/shortcuts/formatLabels'
@@ -93,7 +93,11 @@ export const ParticipantTile: (
const participantColor = getParticipantColor(trackReference.participant) const participantColor = getParticipantColor(trackReference.participant)
const participantName = getParticipantName(trackReference.participant) const { identity, name } = useParticipantInfo({
participant: trackReference.participant,
})
const participantName = name || identity || 'Unknown'
const { t } = useTranslation('rooms', { keyPrefix: 'participantTileFocus' }) const { t } = useTranslation('rooms', { keyPrefix: 'participantTileFocus' })
const interactiveProps = { const interactiveProps = {
@@ -145,14 +149,12 @@ export const ParticipantTile: (
<div className="lk-participant-placeholder"> <div className="lk-participant-placeholder">
<ParticipantPlaceholder <ParticipantPlaceholder
color={participantColor} color={participantColor}
displayedNamed={ displayedNamed={participantName}
trackReference.participant.name ||
trackReference.participant.identity
}
/> />
</div> </div>
{!disableMetadata && ( {!disableMetadata && (
<ParticipantMetadata <ParticipantMetadata
displayedName={participantName}
isScreenShare={isScreenShare} isScreenShare={isScreenShare}
participant={trackReference.participant} participant={trackReference.participant}
/> />