5.11.2: Случайная сторона карточки при каждом показе слова
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m3s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m3s
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "play-life-web",
|
||||
"version": "5.11.1",
|
||||
"version": "5.11.2",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -34,6 +34,7 @@ function TestWords({ onNavigate, wordCount: initialWordCount, configId: initialC
|
||||
const cardsShownRef = useRef(0) // Синхронный счётчик для избежания race condition
|
||||
const saveProgressPromiseRef = useRef(null) // Промис сохранения прогресса (null = ещё не запущено)
|
||||
const savePayloadRef = useRef(null) // Данные для сохранения при нажатии «Закончить» (если сохранение ещё не запускали)
|
||||
const [currentSide, setCurrentSide] = useState(null) // Текущая случайная сторона карточки ('word' или 'translation')
|
||||
|
||||
// Функция равномерного распределения слов в пуле с гарантией максимального расстояния между одинаковыми словами
|
||||
// excludeFirstWordId - ID слова, которое не должно быть первым в пуле (только что показанная карточка)
|
||||
@@ -213,6 +214,7 @@ function TestWords({ onNavigate, wordCount: initialWordCount, configId: initialC
|
||||
setWords([])
|
||||
setTestWords([])
|
||||
setCurrentWord(null)
|
||||
setCurrentSide(null)
|
||||
setFlippedCards(new Set())
|
||||
setWordStats({})
|
||||
wordStatsRef.current = {}
|
||||
@@ -437,6 +439,7 @@ function TestWords({ onNavigate, wordCount: initialWordCount, configId: initialC
|
||||
cardsShownRef.current = nextCardsShown
|
||||
|
||||
setCurrentWord(validWord)
|
||||
setCurrentSide(Math.random() < 0.5 ? 'word' : 'translation')
|
||||
setCardsShown(nextCardsShown)
|
||||
setFlippedCards(new Set())
|
||||
|
||||
@@ -450,6 +453,7 @@ function TestWords({ onNavigate, wordCount: initialWordCount, configId: initialC
|
||||
|
||||
// showCard: показываем карточку
|
||||
setCurrentWord(nextWord)
|
||||
setCurrentSide(Math.random() < 0.5 ? 'word' : 'translation')
|
||||
setCardsShown(nextCardsShown)
|
||||
setFlippedCards(new Set())
|
||||
|
||||
@@ -604,9 +608,6 @@ function TestWords({ onNavigate, wordCount: initialWordCount, configId: initialC
|
||||
}
|
||||
}
|
||||
|
||||
const getRandomSide = (word) => {
|
||||
return word.id % 2 === 0 ? 'word' : 'translation'
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="test-container test-container-fullscreen">
|
||||
@@ -741,10 +742,9 @@ function TestWords({ onNavigate, wordCount: initialWordCount, configId: initialC
|
||||
loadWords()
|
||||
}} />
|
||||
)}
|
||||
{!loading && !error && !isFinishingRef.current && currentWord && (() => {
|
||||
{!loading && !error && !isFinishingRef.current && currentWord && currentSide && (() => {
|
||||
const word = currentWord
|
||||
const isFlipped = flippedCards.has(word.id)
|
||||
const showSide = getRandomSide(word)
|
||||
|
||||
return (
|
||||
<div className="test-card-container" key={word.id}>
|
||||
@@ -754,7 +754,7 @@ function TestWords({ onNavigate, wordCount: initialWordCount, configId: initialC
|
||||
>
|
||||
<div className="test-card-front">
|
||||
<div className="test-card-content">
|
||||
{showSide === 'word' ? (
|
||||
{currentSide === 'word' ? (
|
||||
<div className="test-word">{word.name}</div>
|
||||
) : (
|
||||
<div className="test-translation">{word.translation}</div>
|
||||
@@ -763,7 +763,7 @@ function TestWords({ onNavigate, wordCount: initialWordCount, configId: initialC
|
||||
</div>
|
||||
<div className="test-card-back">
|
||||
<div className="test-card-content">
|
||||
{showSide === 'word' ? (
|
||||
{currentSide === 'word' ? (
|
||||
<div className="test-translation">{word.translation}</div>
|
||||
) : (
|
||||
<div className="test-word">{word.name}</div>
|
||||
|
||||
Reference in New Issue
Block a user