@@ -11,6 +11,7 @@ import {
1111 ParticipantContext ,
1212 useEnsureParticipant ,
1313 useMaybeLayoutContext ,
14+ useMaybeTrackContext ,
1415} from '../../context' ;
1516import { useIsMuted , useIsSpeaking } from '../../hooks' ;
1617import { mergeProps } from '../../utils' ;
@@ -114,12 +115,17 @@ export const ParticipantTile = ({
114115 ...htmlProps
115116} : ParticipantTileProps ) => {
116117 const p = useEnsureParticipant ( participant ) ;
117-
118- const { elementProps } = useParticipantTile < HTMLDivElement > ( {
118+ const trackRef : TrackReferenceOrPlaceholder = useMaybeTrackContext ( ) ?? {
119119 participant : p ,
120- htmlProps,
121120 source,
122121 publication,
122+ } ;
123+
124+ const { elementProps } = useParticipantTile < HTMLDivElement > ( {
125+ participant : trackRef . participant ,
126+ htmlProps,
127+ source : trackRef . source ,
128+ publication : trackRef . publication ,
123129 disableSpeakingIndicator,
124130 onParticipantClick,
125131 } ) ;
@@ -129,37 +135,37 @@ export const ParticipantTile = ({
129135 const handleSubscribe = React . useCallback (
130136 ( subscribed : boolean ) => {
131137 if (
132- source &&
138+ trackRef . source &&
133139 ! subscribed &&
134140 layoutContext &&
135141 layoutContext . pin . dispatch &&
136- isParticipantSourcePinned ( p , source , layoutContext . pin . state )
142+ isParticipantSourcePinned ( trackRef . participant , trackRef . source , layoutContext . pin . state )
137143 ) {
138144 layoutContext . pin . dispatch ( { msg : 'clear_pin' } ) ;
139145 }
140146 } ,
141- [ p , layoutContext , source ] ,
147+ [ trackRef . participant , layoutContext , trackRef . source ] ,
142148 ) ;
143149
144150 return (
145151 < div style = { { position : 'relative' } } { ...elementProps } >
146- < ParticipantContextIfNeeded participant = { p } >
152+ < ParticipantContextIfNeeded participant = { trackRef . participant } >
147153 { children ?? (
148154 < >
149- { publication ?. kind === 'video' ||
150- source === Track . Source . Camera ||
151- source === Track . Source . ScreenShare ? (
155+ { trackRef . publication ?. kind === 'video' ||
156+ trackRef . source === Track . Source . Camera ||
157+ trackRef . source === Track . Source . ScreenShare ? (
152158 < VideoTrack
153- participant = { p }
154- source = { source }
155- publication = { publication }
159+ participant = { trackRef . participant }
160+ source = { trackRef . source }
161+ publication = { trackRef . publication }
156162 onSubscriptionStatusChanged = { handleSubscribe }
157163 />
158164 ) : (
159165 < AudioTrack
160- participant = { p }
161- source = { source }
162- publication = { publication }
166+ participant = { trackRef . participant }
167+ source = { trackRef . source }
168+ publication = { trackRef . publication }
163169 onSubscriptionStatusChanged = { handleSubscribe }
164170 />
165171 ) }
@@ -168,7 +174,7 @@ export const ParticipantTile = ({
168174 </ div >
169175 < div className = "lk-participant-metadata" >
170176 < div className = "lk-participant-metadata-item" >
171- { source === Track . Source . Camera ? (
177+ { trackRef . source === Track . Source . Camera ? (
172178 < >
173179 < TrackMutedIndicator
174180 source = { Track . Source . Microphone }
@@ -187,7 +193,7 @@ export const ParticipantTile = ({
187193 </ div >
188194 </ >
189195 ) }
190- < FocusToggle trackSource = { source } />
196+ < FocusToggle trackSource = { trackRef . source } />
191197 </ ParticipantContextIfNeeded >
192198 </ div >
193199 ) ;
0 commit comments