@@ -6,7 +6,7 @@ import "swiper/swiper-bundle.min.css";
66import "./SpeakersCarousel.scss" ;
77import { Link } from "react-router" ;
88import conferenceData from "../../data/2024.json" ;
9- import { useFetchSpeakers } from "../Speakers/UseFetchSpeakers " ;
9+ import { useFetchSpeakers } from "../../hooks/useFetchSpeakers " ;
1010import * as Sentry from "@sentry/react" ;
1111import { Color } from "../../styles/colors" ;
1212import { ROUTE_SPEAKER_DETAIL } from "../../constants/routes" ;
@@ -36,28 +36,28 @@ const StyledSlideText = styled.p`
3636 color: white;
3737` ;
3838const SpeakerSwiper : FC < React . PropsWithChildren < unknown > > = ( ) => {
39- const { isLoading, data, error} = useFetchSpeakers ( ) ;
39+ const { isLoading, data, error} = useFetchSpeakers ( "2024" ) ;
4040
4141 // Securely shuffle the speakers using Fisher-Yates algorithm with crypto API
4242const swiperSpeakers = React . useMemo ( ( ) => {
4343 if ( ! data ) return null ;
44-
44+
4545 // Create a copy of the data to avoid mutating the original
4646 const speakersCopy = [ ...data ] ;
47-
47+
4848 // Fisher-Yates shuffle with crypto.getRandomValues for secure randomization
4949 for ( let i = speakersCopy . length - 1 ; i > 0 ; i -- ) {
5050 // Generate a secure random value using crypto API
5151 const randomBuffer = new Uint32Array ( 1 ) ;
5252 window . crypto . getRandomValues ( randomBuffer ) ;
53-
53+
5454 // Use the random value to get an index between 0 and i (inclusive)
5555 const j = randomBuffer [ 0 ] % ( i + 1 ) ;
56-
56+
5757 // Swap elements at i and j
5858 [ speakersCopy [ i ] , speakersCopy [ j ] ] = [ speakersCopy [ j ] , speakersCopy [ i ] ] ;
5959 }
60-
60+
6161 // Return the first 20 speakers from the shuffled array
6262 return speakersCopy . slice ( 0 , 20 ) ;
6363} , [ data ] ) ;
0 commit comments