5.11.2: Случайная сторона карточки при каждом показе слова
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m3s

This commit is contained in:
poignatov
2026-03-04 18:28:08 +03:00
parent 6caed05c9f
commit 20773a29b7
3 changed files with 9 additions and 9 deletions

View File

@@ -1 +1 @@
5.11.1
5.11.2

View File

@@ -1,6 +1,6 @@
{
"name": "play-life-web",
"version": "5.11.1",
"version": "5.11.2",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -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>