🌊 Волна 3: frontend юзабилити топ (4 бага)
- HINT_AUTO_SELECTS_CORRECT: подсказка не засчитывается как ответ (PracticeViewPage.tsx, паттерн из LessonViewPage) - ALERT_IN_TELEGRAM_MINIAPP: alert() → кастомный toast (TeacherChatPage.tsx, 3 места) - BUBBLE_ERROR_MESSAGE_STUCK: errorTimeoutRef + автоскрытие (BubbleWordsPage.tsx) - WORDSEARCH_STREAK_ON_ALREADY_FOUND: инкремент внутри проверки includes (WordSearchPage.tsx) Аудит: Issue #3, frontend 4/34 задач
This commit is contained in:
@@ -43,6 +43,9 @@ const BubbleWordsPage: React.FC = () => {
|
|||||||
const isMountedRef = useRef(true);
|
const isMountedRef = useRef(true);
|
||||||
const messageTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
const messageTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
const hintTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
const hintTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
// 🔧 ФИКС (23.09.2026): BUBBLE_ERROR_MESSAGE_STUCK — добавлен таймер для errorMessage,
|
||||||
|
// чтобы плашка автоскрывалась (раньше висела бесконечно).
|
||||||
|
const errorTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
const startTimeRef = useRef<number>(0);
|
const startTimeRef = useRef<number>(0);
|
||||||
const rulesShownRef = useRef(false);
|
const rulesShownRef = useRef(false);
|
||||||
|
|
||||||
@@ -84,6 +87,8 @@ const BubbleWordsPage: React.FC = () => {
|
|||||||
isMountedRef.current = false;
|
isMountedRef.current = false;
|
||||||
if (messageTimeoutRef.current) clearTimeout(messageTimeoutRef.current);
|
if (messageTimeoutRef.current) clearTimeout(messageTimeoutRef.current);
|
||||||
if (hintTimeoutRef.current) clearTimeout(hintTimeoutRef.current);
|
if (hintTimeoutRef.current) clearTimeout(hintTimeoutRef.current);
|
||||||
|
// 🔧 ФИКС (23.09.2026): BUBBLE_ERROR_MESSAGE_STUCK — cleanup нового таймера
|
||||||
|
if (errorTimeoutRef.current) clearTimeout(errorTimeoutRef.current);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -150,6 +155,17 @@ const BubbleWordsPage: React.FC = () => {
|
|||||||
}, 1500);
|
}, 1500);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 🔧 ФИКС (23.09.2026): BUBBLE_ERROR_MESSAGE_STUCK — helper для errorMessage
|
||||||
|
// с автоскрытием через 2 секунды (по аналогии с showMessage).
|
||||||
|
const showError = (msg: string) => {
|
||||||
|
if (!isMountedRef.current) return;
|
||||||
|
setErrorMessage(msg);
|
||||||
|
if (errorTimeoutRef.current) clearTimeout(errorTimeoutRef.current);
|
||||||
|
errorTimeoutRef.current = setTimeout(() => {
|
||||||
|
if (isMountedRef.current) setErrorMessage(null);
|
||||||
|
}, 2000);
|
||||||
|
};
|
||||||
|
|
||||||
const handleBubbleClick = useCallback((bubble: Bubble) => {
|
const handleBubbleClick = useCallback((bubble: Bubble) => {
|
||||||
if (completed || isTransitioning) return;
|
if (completed || isTransitioning) return;
|
||||||
if (foundWords.includes(bubble.word_pl)) return;
|
if (foundWords.includes(bubble.word_pl)) return;
|
||||||
@@ -231,7 +247,8 @@ const BubbleWordsPage: React.FC = () => {
|
|||||||
|
|
||||||
const handleFirstLetterHint = () => {
|
const handleFirstLetterHint = () => {
|
||||||
if (firstLetterHintsUsed >= maxFirstLetterHints) {
|
if (firstLetterHintsUsed >= maxFirstLetterHints) {
|
||||||
setErrorMessage('⚠️ ' + (t('noMoreFirstLetterHints') || 'No more hints'));
|
// 🔧 ФИКС (23.09.2026): BUBBLE_ERROR_MESSAGE_STUCK — используем showError
|
||||||
|
showError('⚠️ ' + (t('noMoreFirstLetterHints') || 'No more hints'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,20 +113,22 @@ const PracticeViewPage: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 🔧 ИСПРАВЛЕНО: handleHintClick теперь сохраняет ответ с hintUsed=true
|
// 🔧 ФИКС (23.09.2026): HINT_AUTO_SELECTS_CORRECT — подсказка больше НЕ засчитывается как ответ.
|
||||||
|
// Было: saveAnswer(..., correctAnswer, true, true) + setSelectedAnswers(correctAnswer)
|
||||||
|
// → ученик жал «💡 Подсказка», и вопрос засчитывался как правильный без решения.
|
||||||
|
// Стало: подсказка — только UI. Отправляем факт подсказки с isFinalAnswer=false,
|
||||||
|
// пустым ответом. Вариант в UI НЕ выбирается автоматически.
|
||||||
|
// Кнопка «Далее» ждёт, пока ученик сам выберет ответ.
|
||||||
|
// Паттерн скопирован из LessonViewPage.handleHintClick.
|
||||||
const handleHintClick = async () => {
|
const handleHintClick = async () => {
|
||||||
if (!currentQuestion || hintUsed[currentQuestion.question.question_id]) return;
|
if (!currentQuestion || hintUsed[currentQuestion.question.question_id]) return;
|
||||||
|
|
||||||
setHintUsed(prev => ({ ...prev, [currentQuestion.question.question_id]: true }));
|
setHintUsed(prev => ({ ...prev, [currentQuestion.question.question_id]: true }));
|
||||||
setShowHint(true);
|
setShowHint(true);
|
||||||
|
|
||||||
const correctOption = currentQuestion.options.find(o => o.is_correct);
|
// 🔧 Логируем факт подсказки — но НЕ как финальный ответ.
|
||||||
const correctAnswer = correctOption ? correctOption.option_key : '';
|
// Пустой answer, isFinalAnswer=false, usedHint=true.
|
||||||
// 🔧 ИСПРАВЛЕНО: isFinalAnswer=true, hintUsed=true — система будет знать, что была подсказка
|
await saveAnswer(currentQuestion.question.question_id, '', false, true);
|
||||||
await saveAnswer(currentQuestion.question.question_id, correctAnswer, true, true);
|
|
||||||
|
|
||||||
// 🔧 НОВОЕ: также отмечаем ответ как выбранный, чтобы кнопка "Далее" стала активной
|
|
||||||
setSelectedAnswers(prev => ({ ...prev, [currentQuestion.question.question_id]: correctAnswer }));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleNext = async () => {
|
const handleNext = async () => {
|
||||||
|
|||||||
@@ -97,6 +97,8 @@ const TeacherChatPage: React.FC = () => {
|
|||||||
const [examplesError, setExamplesError] = useState<string | null>(null);
|
const [examplesError, setExamplesError] = useState<string | null>(null);
|
||||||
const [isStartingPractice, setIsStartingPractice] = useState(false);
|
const [isStartingPractice, setIsStartingPractice] = useState(false);
|
||||||
const [playingExampleLine, setPlayingExampleLine] = useState<number | null>(null);
|
const [playingExampleLine, setPlayingExampleLine] = useState<number | null>(null);
|
||||||
|
// 🔧 ФИКС (23.09.2026): ALERT_IN_TELEGRAM_MINIAPP — заменяем alert() на кастомный toast
|
||||||
|
const [toastMessage, setToastMessage] = useState<string | null>(null);
|
||||||
|
|
||||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
@@ -124,6 +126,14 @@ const TeacherChatPage: React.FC = () => {
|
|||||||
return text.includes('🇵🇱') || text.includes('→') || /[ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]/.test(text);
|
return text.includes('🇵🇱') || text.includes('→') || /[ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]/.test(text);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 🔧 ФИКС (23.09.2026): ALERT_IN_TELEGRAM_MINIAPP — helper для toast вместо alert()
|
||||||
|
const showToast = (msg: string) => {
|
||||||
|
setToastMessage(msg);
|
||||||
|
setTimeout(() => {
|
||||||
|
setToastMessage(null);
|
||||||
|
}, 2500);
|
||||||
|
};
|
||||||
|
|
||||||
const isFreeQuestion = (text: string): boolean => {
|
const isFreeQuestion = (text: string): boolean => {
|
||||||
const trimmed = text.trim();
|
const trimmed = text.trim();
|
||||||
if (trimmed.endsWith('?')) return true;
|
if (trimmed.endsWith('?')) return true;
|
||||||
@@ -661,7 +671,8 @@ const TeacherChatPage: React.FC = () => {
|
|||||||
try {
|
try {
|
||||||
const analytics = await getLearningAnalytics();
|
const analytics = await getLearningAnalytics();
|
||||||
if (!analytics.has_practice_available) {
|
if (!analytics.has_practice_available) {
|
||||||
alert(t('testPracticeNoWeak'));
|
// 🔧 ФИКС (23.09.2026): ALERT_IN_TELEGRAM_MINIAPP — toast вместо alert()
|
||||||
|
showToast(t('testPracticeNoWeak'));
|
||||||
setIsStartingPractice(false);
|
setIsStartingPractice(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -676,12 +687,14 @@ const TeacherChatPage: React.FC = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
alert(data.message || t('testPracticeNoWeak'));
|
// 🔧 ФИКС (23.09.2026): ALERT_IN_TELEGRAM_MINIAPP — toast вместо alert()
|
||||||
|
showToast(data.message || t('testPracticeNoWeak'));
|
||||||
setIsStartingPractice(false);
|
setIsStartingPractice(false);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error starting practice:', e);
|
console.error('Error starting practice:', e);
|
||||||
alert(t('teacherAIError'));
|
// 🔧 ФИКС (23.09.2026): ALERT_IN_TELEGRAM_MINIAPP — toast вместо alert()
|
||||||
|
showToast(t('teacherAIError'));
|
||||||
setIsStartingPractice(false);
|
setIsStartingPractice(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -746,6 +759,29 @@ const TeacherChatPage: React.FC = () => {
|
|||||||
<div style={{ position: 'fixed', top: '-80px', right: '-60px', width: '260px', height: '260px', borderRadius: '50%', background: teacherColor, opacity: 0.18, filter: 'blur(90px)', pointerEvents: 'none', zIndex: 0 }} />
|
<div style={{ position: 'fixed', top: '-80px', right: '-60px', width: '260px', height: '260px', borderRadius: '50%', background: teacherColor, opacity: 0.18, filter: 'blur(90px)', pointerEvents: 'none', zIndex: 0 }} />
|
||||||
<div style={{ position: 'fixed', bottom: '-50px', left: '-40px', width: '240px', height: '240px', borderRadius: '50%', background: brandColor, opacity: 0.14, filter: 'blur(80px)', pointerEvents: 'none', zIndex: 0 }} />
|
<div style={{ position: 'fixed', bottom: '-50px', left: '-40px', width: '240px', height: '240px', borderRadius: '50%', background: brandColor, opacity: 0.14, filter: 'blur(80px)', pointerEvents: 'none', zIndex: 0 }} />
|
||||||
|
|
||||||
|
{/* 🔧 ФИКС (23.09.2026): ALERT_IN_TELEGRAM_MINIAPP — кастомный toast вместо alert() */}
|
||||||
|
{toastMessage && (
|
||||||
|
<div style={{
|
||||||
|
position: 'fixed',
|
||||||
|
top: '20px',
|
||||||
|
left: '50%',
|
||||||
|
transform: 'translateX(-50%)',
|
||||||
|
zIndex: 999,
|
||||||
|
padding: '12px 20px',
|
||||||
|
background: 'rgba(26,26,46,0.95)',
|
||||||
|
color: '#FFFFFF',
|
||||||
|
fontSize: '14px',
|
||||||
|
fontWeight: 600,
|
||||||
|
borderRadius: radius.md,
|
||||||
|
boxShadow: '0 8px 24px rgba(0,0,0,0.25)',
|
||||||
|
maxWidth: '90vw',
|
||||||
|
textAlign: 'center',
|
||||||
|
animation: 'modalFadeIn 0.25s ease',
|
||||||
|
}}>
|
||||||
|
{toastMessage}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<style>{`
|
<style>{`
|
||||||
@keyframes fadeInUp {
|
@keyframes fadeInUp {
|
||||||
0% { transform: translateY(10px); opacity: 0; }
|
0% { transform: translateY(10px); opacity: 0; }
|
||||||
|
|||||||
@@ -215,9 +215,12 @@ const WordSearchPage: React.FC = () => {
|
|||||||
const foundWord = checkWordMatch(cells);
|
const foundWord = checkWordMatch(cells);
|
||||||
|
|
||||||
if (foundWord) {
|
if (foundWord) {
|
||||||
perfectStreakRef.current += 1;
|
// 🔧 ФИКС (23.09.2026): WORDSEARCH_STREAK_ON_ALREADY_FOUND —
|
||||||
|
// раньше perfectStreakRef инкрементился ДО проверки includes,
|
||||||
|
// поэтому повторное выделение уже найденного слова завышало streak.
|
||||||
|
// Теперь инкремент только для НОВОГО слова.
|
||||||
if (!foundWordsRef.current.includes(foundWord)) {
|
if (!foundWordsRef.current.includes(foundWord)) {
|
||||||
|
perfectStreakRef.current += 1;
|
||||||
const newFoundWords = [...foundWordsRef.current, foundWord];
|
const newFoundWords = [...foundWordsRef.current, foundWord];
|
||||||
foundWordsRef.current = newFoundWords;
|
foundWordsRef.current = newFoundWords;
|
||||||
setFoundWords(newFoundWords);
|
setFoundWords(newFoundWords);
|
||||||
|
|||||||
Reference in New Issue
Block a user