@@ -12,7 +12,7 @@ import ProgressBar from '@cloudscape-design/components/progress-bar';
1212import SpaceBetween from '@cloudscape-design/components/space-between' ;
1313import StatusIndicator from '@cloudscape-design/components/status-indicator' ;
1414import { UserGroups } from '@deepracer-indy/typescript-client' ;
15- import { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
15+ import { useCallback , useEffect , useRef , useState } from 'react' ;
1616import { useTranslation } from 'react-i18next' ;
1717import { useParams , useSearchParams } from 'react-router-dom' ;
1818
@@ -34,7 +34,7 @@ import {
3434 useReorderLiveQueueMutation ,
3535 useResetLiveQueueModelMutation ,
3636} from '#services/deepRacer/leaderboardsApi.js' ;
37- import { useGetProfileQuery , useListProfilesQuery } from '#services/deepRacer/profileApi.js' ;
37+ import { useGetProfileQuery } from '#services/deepRacer/profileApi.js' ;
3838import { displayInfoNotification , displaySuccessNotification } from '#store/notifications/notificationsSlice.js' ;
3939import { checkUserGroupMembership } from '#utils/authUtils.js' ;
4040import { millisToMinutesAndSeconds } from '#utils/dateTimeUtils.js' ;
@@ -88,7 +88,6 @@ const LiveRace = ({ __forceFacilitator }: LiveRaceProps = {}) => {
8888 ) ;
8989 const { data : leaderboard } = useGetLeaderboardQuery ( { leaderboardId } ) ;
9090 const { data : profile } = useGetProfileQuery ( ) ;
91- const { data : profilesData } = useListProfilesQuery ( ) ;
9291
9392 // Seed reducer state from REST response
9493 useEffect ( ( ) => {
@@ -115,6 +114,7 @@ const LiveRace = ({ __forceFacilitator }: LiveRaceProps = {}) => {
115114 ? {
116115 participantName : liveRaceState . currentEvaluation . participantName ,
117116 modelName : liveRaceState . currentEvaluation . modelName ,
117+ currentAvatar : liveRaceState . currentEvaluation . avatar ?? null ,
118118 streamUrl : liveRaceState . currentEvaluation . streamUrl ?? null ,
119119 isExecutionRunning : true ,
120120 }
@@ -138,10 +138,6 @@ const LiveRace = ({ __forceFacilitator }: LiveRaceProps = {}) => {
138138
139139 // Seed queue items from REST response
140140 const lastQueueRef = useRef < string > ( '' ) ;
141- const profileAvatarMap = useMemo (
142- ( ) => new Map ( ( profilesData ?? [ ] ) . map ( ( p ) => [ p . profileId , p . avatar ] ) ) ,
143- [ profilesData ] ,
144- ) ;
145141 useEffect ( ( ) => {
146142 if ( ! liveQueueData ?. items ) return ;
147143 const key = liveQueueData . items . map ( ( i ) => `${ i . submissionId } :${ i . status } ` ) . join ( ',' ) ;
@@ -155,7 +151,7 @@ const LiveRace = ({ __forceFacilitator }: LiveRaceProps = {}) => {
155151 queuePosition : item . queuePosition ,
156152 status : item . status as 'PENDING' | 'IN_PROGRESS' | 'COMPLETED' | 'FAILED' ,
157153 submittedAt : typeof item . submittedAt === 'string' ? item . submittedAt : new Date ( item . submittedAt ) . toISOString ( ) ,
158- avatar : profileAvatarMap . get ( item . profileId ) ,
154+ avatar : item . avatar ,
159155 } ) ) ;
160156 const nextPending = items . find ( ( i ) => i . status === 'PENDING' ) ;
161157 setRaceState ( ( prev ) => ( {
@@ -169,25 +165,7 @@ const LiveRace = ({ __forceFacilitator }: LiveRaceProps = {}) => {
169165 }
170166 : { } ) ,
171167 } ) ) ;
172- } , [ liveQueueData , profileAvatarMap ] ) ;
173-
174- // When profiles load after queue items, back-fill avatars on existing queue items
175- useEffect ( ( ) => {
176- if ( ! profilesData ?. length ) return ;
177- setRaceState ( ( prev ) => {
178- const enriched = prev . queueItems . map ( ( item ) =>
179- item . avatar ? item : { ...item , avatar : profileAvatarMap . get ( item . profileId ?? '' ) } ,
180- ) ;
181- const currentItem = enriched . find (
182- ( i ) => i . participantName === prev . participantName && i . status === 'IN_PROGRESS' ,
183- ) ;
184- return {
185- ...prev ,
186- queueItems : enriched ,
187- currentAvatar : currentItem ?. avatar ?? prev . currentAvatar ,
188- } ;
189- } ) ;
190- } , [ profilesData , profileAvatarMap ] ) ;
168+ } , [ liveQueueData ] ) ;
191169
192170 // Check facilitator role
193171
0 commit comments