File tree Expand file tree Collapse file tree
client/app/components/vote Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,12 +13,20 @@ import {
1313 usePositions ,
1414 useResults ,
1515 useWS ,
16+ type Candidate ,
1617} from "./queries" ;
1718import { Button } from "../ui/button" ;
1819import { Logo } from "../ui/logo" ;
1920import { Link } from "react-router" ;
2021import { useTheme } from "../theme-provider" ;
2122
23+ function randomize ( array : Candidate [ ] ) {
24+ for ( let i = array . length - 1 ; i > 0 ; i -- ) {
25+ const j = Math . floor ( Math . random ( ) * ( i + 1 ) ) ;
26+ [ array [ i ] , array [ j ] ] = [ array [ j ] , array [ i ] ] ;
27+ }
28+ }
29+
2230const Vote = ( { logout } : { logout : ( ) => void } ) => {
2331 const { setTheme, theme } = useTheme ( ) ;
2432 const isDarkMode = theme === "dark" ;
@@ -34,6 +42,8 @@ const Vote = ({ logout }: { logout: () => void }) => {
3442 if ( wsData ?. status === "finished" ) refetchElected ( ) ;
3543 } , [ wsData ?. status ] ) ;
3644
45+ randomize ( candidates ) ;
46+
3747 return (
3848 < >
3949 < header className = "flex justify-between py-1 px-4" >
You can’t perform that action at this time.
0 commit comments