mirror of
https://github.com/acid-info/logos-ordinals-dashboard.git
synced 2025-02-10 04:14:22 +00:00
feat: shuffle operators
This commit is contained in:
parent
894d30c55f
commit
e116d09fc0
@ -12,7 +12,7 @@ import {
|
|||||||
SKIN,
|
SKIN,
|
||||||
} from '../../../constants/operators'
|
} from '../../../constants/operators'
|
||||||
import { Archetype } from '../../../types/operators'
|
import { Archetype } from '../../../types/operators'
|
||||||
import { processOperators } from '../../../utils/operators'
|
import { processOperators, shuffleOperators } from '../../../utils/operators'
|
||||||
|
|
||||||
interface ExploreSectionProps {}
|
interface ExploreSectionProps {}
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ const ExploreSection: React.FC<ExploreSectionProps> = () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
const randomizedOperators = selectedOperators?.sort(() => Math.random() - 0.5)
|
const randomizedOperators = shuffleOperators(selectedOperators)
|
||||||
|
|
||||||
const handleFilterChange = (
|
const handleFilterChange = (
|
||||||
selectedOptions: string[],
|
selectedOptions: string[],
|
||||||
|
@ -68,3 +68,13 @@ export function findOperatorById(
|
|||||||
(operator) => String(operator.id) === String(operatorId),
|
(operator) => String(operator.id) === String(operatorId),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function shuffleOperators(
|
||||||
|
array: ProcessedOperator[],
|
||||||
|
): ProcessedOperator[] {
|
||||||
|
for (let i = array?.length - 1; i > 0; i--) {
|
||||||
|
const j = Math.floor(Math.random() * (i + 1))
|
||||||
|
;[array[i], array[j]] = [array[j], array[i]]
|
||||||
|
}
|
||||||
|
return array
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user