@@ -217,27 +217,30 @@ const WebhookInspector: React.FC<Props> = ({ userPath, selectedDeviceId = null,
217217 return Array . from ( types ) . sort ( ) ;
218218 } , [ allEvents ] ) ;
219219
220- const filtered = React . useMemo ( ( ) => {
221- let result = allEvents ;
222-
220+ // Check if an event should be visible based on filters
221+ const isEventVisible = React . useCallback ( ( e : EventItem ) => {
223222 // Filter by Device/Bay if applicable
224223 if ( selectedDeviceId || selectedBayId ) {
225- result = result . filter ( e => {
226- const deviceId = getDeviceIdFromEvent ( e ) ;
227- if ( ! deviceId ) return false ;
228- if ( selectedDeviceId && String ( deviceId ) === String ( selectedDeviceId ) ) return true ;
229- if ( selectedBayId && String ( deviceId ) === String ( selectedBayId ) ) return true ;
224+ const deviceId = getDeviceIdFromEvent ( e ) ;
225+ if ( ! deviceId ) return false ;
226+ if ( selectedDeviceId && String ( deviceId ) !== String ( selectedDeviceId ) &&
227+ ! ( selectedBayId && String ( deviceId ) === String ( selectedBayId ) ) ) {
230228 return false ;
231- } ) ;
229+ }
232230 }
233231
234232 // Filter by selected event types
235- if ( selectedEventTypes . size > 0 ) {
236- result = result . filter ( e => selectedEventTypes . has ( e . eventType ) ) ;
233+ if ( selectedEventTypes . size > 0 && ! selectedEventTypes . has ( e . eventType ) ) {
234+ return false ;
237235 }
238236
239- return result ;
240- } , [ allEvents , selectedDeviceId , selectedBayId , selectedEventTypes ] ) ;
237+ return true ;
238+ } , [ selectedDeviceId , selectedBayId , selectedEventTypes ] ) ;
239+
240+ // Get visible events for selection indexing
241+ const visibleEvents = React . useMemo ( ( ) => {
242+ return allEvents . filter ( isEventVisible ) ;
243+ } , [ allEvents , isEventVisible ] ) ;
241244
242245 // Close dropdown when clicking outside
243246 React . useEffect ( ( ) => {
@@ -260,7 +263,7 @@ const WebhookInspector: React.FC<Props> = ({ userPath, selectedDeviceId = null,
260263 if ( el && typeof el . scrollIntoView === 'function' ) {
261264 el . scrollIntoView ( { block : 'nearest' , inline : 'nearest' } ) ;
262265 }
263- } , [ selectedIndex , filtered ] ) ;
266+ } , [ selectedIndex , visibleEvents ] ) ;
264267
265268 // clear local events when requested
266269 React . useEffect ( ( ) => {
@@ -313,19 +316,19 @@ const WebhookInspector: React.FC<Props> = ({ userPath, selectedDeviceId = null,
313316 } ;
314317
315318 const onListKeyDown = ( ev : React . KeyboardEvent ) => {
316- if ( filtered . length === 0 ) return ;
319+ if ( visibleEvents . length === 0 ) return ;
317320 if ( ev . key === 'ArrowDown' ) {
318321 ev . preventDefault ( ) ;
319322 if ( selectedIndex === null ) setSelectedIndex ( 0 ) ;
320- else setSelectedIndex ( Math . min ( filtered . length - 1 , selectedIndex + 1 ) ) ;
323+ else setSelectedIndex ( Math . min ( visibleEvents . length - 1 , selectedIndex + 1 ) ) ;
321324 } else if ( ev . key === 'ArrowUp' ) {
322325 ev . preventDefault ( ) ;
323- if ( selectedIndex === null ) setSelectedIndex ( filtered . length - 1 ) ;
326+ if ( selectedIndex === null ) setSelectedIndex ( visibleEvents . length - 1 ) ;
324327 else setSelectedIndex ( Math . max ( 0 , selectedIndex - 1 ) ) ;
325328 }
326329 } ;
327330
328- const selectedEvent = selectedIndex === null ? null : filtered [ selectedIndex ] ;
331+ const selectedEvent = selectedIndex === null ? null : visibleEvents [ selectedIndex ] ;
329332
330333 const getEventModelPayload = ( e : EventItem ) => {
331334 try {
@@ -417,8 +420,6 @@ const WebhookInspector: React.FC<Props> = ({ userPath, selectedDeviceId = null,
417420 }
418421 }
419422
420- console . log ( "MICHAEL" , payload ) ;
421-
422423 console . log ( '[ShotFinish] Final measurement before adding Actuals:' , Object . keys ( strokeCompletedMeasurement ) ) ;
423424
424425 // Add the "Actual" fields from ShotFinish
@@ -626,16 +627,22 @@ const WebhookInspector: React.FC<Props> = ({ userPath, selectedDeviceId = null,
626627 </ div >
627628 </ div >
628629 < ul className = "webhook-events-ul" ref = { listRef } >
629- { filtered . length === 0 ? (
630+ { visibleEvents . length === 0 ? (
630631 < li className = "no-events" > No events yet.</ li >
631632 ) : (
632- filtered . map ( ( e , idx ) => {
633+ allEvents . map ( ( e , allIdx ) => {
634+ const isVisible = isEventVisible ( e ) ;
635+ if ( ! isVisible ) return null ; // Skip rendering hidden items
636+
637+ // Find the visible index for this event
638+ const visibleIdx = visibleEvents . findIndex ( ve => ve === e ) ;
639+
633640 const { customerSessionId, activitySessionId } = getSessionIds ( e ) ;
634641 const customerColor = getColorForId ( customerSessionId , customerSessionColors ) ;
635642 const activityColor = getColorForId ( activitySessionId , activitySessionColors ) ;
636643
637644 return (
638- < li key = { e . id || idx } className = { `webhook-event-item ${ selectedIndex === idx ? 'selected' : '' } ` } onClick = { ( ) => select ( idx ) } >
645+ < li key = { e . id || allIdx } className = { `webhook-event-item ${ selectedIndex === visibleIdx ? 'selected' : '' } ` } onClick = { ( ) => select ( visibleIdx ) } >
639646 < div className = "event-type" > { e . eventType } </ div >
640647 < div className = "event-meta" > { new Date ( e . timestamp ) . toLocaleString ( ) } </ div >
641648 < div className = "event-session-indicators" >
@@ -675,11 +682,11 @@ const WebhookInspector: React.FC<Props> = ({ userPath, selectedDeviceId = null,
675682 const sessionData = getSessionData ( activitySessionId ) ;
676683 if ( sessionData && ( sessionData . courseInfo || sessionData . isLoadingCourse ) ) {
677684 // Find the most recent ChangePlayer data for this event
678- const changePlayerData = findRecentChangePlayerData ( selectedEvent , filtered ) ;
685+ const changePlayerData = findRecentChangePlayerData ( selectedEvent , allEvents ) ;
679686
680687 // Find all shots for the current hole
681688 const shots : ShotData [ ] = changePlayerData ?. hole
682- ? findAllShotsForHole ( selectedEvent , filtered , changePlayerData . hole )
689+ ? findAllShotsForHole ( selectedEvent , allEvents , changePlayerData . hole )
683690 : [ ] ;
684691
685692 return (
@@ -700,7 +707,7 @@ const WebhookInspector: React.FC<Props> = ({ userPath, selectedDeviceId = null,
700707 { /* Check if this is a measurement event - show tiles view instead of JSON */ }
701708 { ( ( ) => {
702709 if ( isMeasurementEvent ( selectedEvent ) ) {
703- const measurementData = getMeasurementData ( selectedEvent , filtered ) ;
710+ const measurementData = getMeasurementData ( selectedEvent , allEvents ) ;
704711 if ( measurementData && measurementData . measurement ) {
705712 return (
706713 < MeasurementTilesView
0 commit comments