@@ -136,6 +136,7 @@ export default function Home(props: ResolvedUrlData) {
136136 const loadMatches = async ( silent : boolean = false ) => {
137137 if ( ! silent )
138138 setLoadingMatches ( true ) ;
139+
139140 window . location . hash = "" ;
140141 const matches : Match [ ] = await api . allCompetitionMatches ( comp ?. _id ) ;
141142 matches . sort ( ( a , b ) => {
@@ -156,13 +157,15 @@ export default function Home(props: ResolvedUrlData) {
156157 ) ;
157158
158159 setMatches ( matches ) ;
160+
159161 if ( ! silent )
160162 setLoadingMatches ( false ) ;
161163 } ;
162164
163- const loadReports = async ( ) => {
165+ const loadReports = async ( silent : boolean = false ) => {
164166 const scoutingStats = ( reps : Report [ ] ) => {
165- setLoadingScoutStats ( true ) ;
167+ if ( ! silent )
168+ setLoadingScoutStats ( true ) ;
166169 let submittedCount = 0 ;
167170 reps . forEach ( ( report ) => {
168171 if ( report . submitted ) {
@@ -171,10 +174,12 @@ export default function Home(props: ResolvedUrlData) {
171174 } ) ;
172175
173176 setSubmittedReports ( submittedCount ) ;
174- setLoadingScoutStats ( false ) ;
177+ if ( ! silent )
178+ setLoadingScoutStats ( false ) ;
175179 } ;
176180
177- setLoadingReports ( true ) ;
181+ if ( ! silent )
182+ setLoadingReports ( true ) ;
178183 const newReports : Report [ ] = await api . competitionReports (
179184 comp ?. _id ,
180185 false
@@ -188,10 +193,15 @@ export default function Home(props: ResolvedUrlData) {
188193 newReportId [ report . _id ] = report ;
189194 } ) ;
190195 setReportsById ( newReportId ) ;
191- setLoadingReports ( false ) ;
196+ if ( ! silent )
197+ setLoadingReports ( false ) ;
192198 scoutingStats ( newReports ) ;
193199 } ;
194200
201+ useEffect ( ( ) => {
202+ setInterval ( ( ) => loadReports ( true ) , 5000 ) ;
203+ } , [ ] ) ;
204+
195205 useEffect ( ( ) => {
196206 const loadUsers = async ( ) => {
197207 setLoadingUsers ( true ) ;
@@ -887,6 +897,11 @@ export default function Home(props: ResolvedUrlData) {
887897 : "bg-blue-500"
888898 : "bg-slate-500" ;
889899 color = ours ? ! report . submitted ? "bg-purple-500" : "bg-purple-300" : color ;
900+
901+ if ( ! report ) return < > </ > ;
902+
903+ const timeSinceCheckIn = report . checkInTimestamp && ( new Date ( ) . getTime ( ) - new Date ( report . checkInTimestamp as any ) . getTime ( ) ) / 1000 ;
904+
890905 return (
891906 < Link
892907 href = { `/${ team ?. slug } /${ season ?. slug } /${ comp ?. slug } /${ reportId } ` }
@@ -895,7 +910,7 @@ export default function Home(props: ResolvedUrlData) {
895910 mine && ! submitted
896911 ? "border-4"
897912 : "border-2"
898- } rounded-lg w-12 h-12 flex items-center justify-center text-white border-white`}
913+ } ${ timeSinceCheckIn && timeSinceCheckIn < 10 && "avatar online" } rounded-lg w-12 h-12 flex items-center justify-center text-white border-white`}
899914 >
900915 < h1 > { report . robotNumber } </ h1 >
901916 </ Link >
0 commit comments