🌊 Волна 16: frontend #6 — юзабилити + типы (15 багов)

Юзабилити:
- BUBBLE_MESSAGE_OVERLAP: message/errorMessage взаимоисключение (BubbleWordsPage.tsx)
- REGISTER_FAILURE_NO_RETRY_IN_SESSION: retry с backoff (App.tsx)
- TESTVIEW_DUPLICATE_SAVE: убран дубль saveAnswer (TestViewPage.tsx)
- TEACHER_TOAST_NO_CLEANUP: clearTimeout (TeacherChatPage.tsx)
- TESTVIEW_TOAST_NO_CLEANUP: clearTimeout (TestViewPage.tsx)

Производительность:
- MENU_LEADERBOARD_HEAVY_FETCH: limit 100→50 (MenuPage.tsx)
- FLASHCARDS_RETRACK_ON_ACHIEVEMENT: одноразовый трекинг (FlashcardsPage.tsx)
- TEACHER_HISTORY_SAVE_EVERY_MESSAGE: debounce 500мс (TeacherChatPage.tsx)
- LEADERBOARD_GETUSERID_EVERY_RENDER: useState initializer (LeaderboardPage.tsx)

Типы:
- ANY_TYPES_PERSONAL_STATS + ADMIN_STATS: интерфейсы (api.ts)
- ANY_TYPES_LESSON_FULL: LessonFullResponse (api.ts)

Качество:
- SILENT_ERROR_SWALLOWING_APP: console.warn (App.tsx)
- STALE_CLOSURE_NAVIGATE_SETLANG: useRef для navigate/setLang (App.tsx)
- FETCH_JSON_NO_CONTENT_TYPE_CHECK: проверка content-type (api.ts)

Пропущено осознанно:
- INIT_DATA_IN_URL_DELETE_FEED (Cloudflare preflight)

Аудит v4: Issue #6, frontend 15/16 задач
This commit is contained in:
2026-09-24 20:00:59 +03:00
parent 87f482861b
commit 5c27b98f4b
8 changed files with 221 additions and 56 deletions
+24 -4
View File
@@ -110,6 +110,11 @@ const TeacherChatPage: React.FC = () => {
// на КАЖДЫЙ рендер — O(n) при длинном чате. Теперь useRef(0),
// а актуальное значение ставится один раз при загрузке истории (в useEffect).
const idRef = useRef(0);
// 🔧 ФИКС (24.09.2026): TEACHER_TOAST_NO_CLEANUP —
// храним таймер для очистки.
const toastTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
// 🔧 ФИКС (24.09.2026): TEACHER_HISTORY_SAVE_EVERY_MESSAGE
const historySaveTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const startTimeRef = useRef<number>(Date.now());
const brandColor = '#2ECC71';
@@ -133,9 +138,11 @@ const TeacherChatPage: React.FC = () => {
};
// 🔧 ФИКС (23.09.2026): ALERT_IN_TELEGRAM_MINIAPP — helper для toast вместо alert()
// 🔧 ФИКС (24.09.2026): TEACHER_TOAST_NO_CLEANUP — сохраняем таймер.
const showToast = (msg: string) => {
setToastMessage(msg);
setTimeout(() => {
if (toastTimeoutRef.current) clearTimeout(toastTimeoutRef.current);
toastTimeoutRef.current = setTimeout(() => {
setToastMessage(null);
}, 2500);
};
@@ -240,15 +247,23 @@ const TeacherChatPage: React.FC = () => {
.catch(() => {});
}, []);
// 🔧 ФИКС (24.09.2026): TEACHER_HISTORY_SAVE_EVERY_MESSAGE —
// дебаунсим сохранение истории на сервер (500мс), чтобы не долбить
// бэк при каждом новом сообщении.
useEffect(() => {
try {
localStorage.setItem(STORAGE_KEY, JSON.stringify(messages));
if (messages.length > 0) {
saveTeacherHistory(messages).catch(() => {});
}
} catch (e) {
// ignore
}
if (messages.length === 0) return;
if (historySaveTimeoutRef.current) clearTimeout(historySaveTimeoutRef.current);
historySaveTimeoutRef.current = setTimeout(() => {
saveTeacherHistory(messages).catch(() => {});
}, 500);
return () => {
if (historySaveTimeoutRef.current) clearTimeout(historySaveTimeoutRef.current);
};
}, [messages]);
const extractPolishText = (text: string): string => {
@@ -403,6 +418,11 @@ const TeacherChatPage: React.FC = () => {
try { URL.revokeObjectURL(audioUrlRef.current); } catch { /* ignore */ }
audioUrlRef.current = null;
}
// 🔧 ФИКС (24.09.2026): TEACHER_TOAST_NO_CLEANUP
if (toastTimeoutRef.current) {
clearTimeout(toastTimeoutRef.current);
toastTimeoutRef.current = null;
}
if ('speechSynthesis' in window) {
window.speechSynthesis.cancel();
}