topics-fix-2

This commit is contained in:
Untone 2024-05-06 13:46:00 +03:00
parent 1b1f3441dd
commit 28022607e3

View File

@ -2,6 +2,7 @@ import { RANDOM_TOPICS_COUNT } from '../components/Views/Home'
import { Topic } from '../graphql/schema/core.gen'
export const getRandomTopicsFromArray = (topics: Topic[], count: number = RANDOM_TOPICS_COUNT): Topic[] => {
const shuffledTopics = [...(topics || [])].sort(() => 0.5 - Math.random())
if (!topics) return []
const shuffledTopics = [...topics].sort(() => 0.5 - Math.random())
return shuffledTopics.slice(0, count)
}