From 06f80d181e8d7e7e49193b71bb4f1a6b13db3326 Mon Sep 17 00:00:00 2001 From: AliReza Date: Sun, 18 Oct 2026 18:27:44 +0330 Subject: [PATCH] Quiz: phone Back asks before leaving; unknown hearts are not shown as five full Co-Authored-By: Claude Opus 5.5 --- src/screens/QuizScreen.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/screens/QuizScreen.tsx b/src/screens/QuizScreen.tsx index 8ae69b6..4eed299 100644 --- a/src/screens/QuizScreen.tsx +++ b/src/screens/QuizScreen.tsx @@ -5,7 +5,7 @@ import { api, ApiError, type AnswerResult, type Hearts, type Question } from '@/ import { useAppData } from '@/state/AppData'; import { fetchHome } from '@/state/subject'; import { findNode, findNodeOfLesson, nextLessonOf, unitColor } from '@/state/curriculum'; -import { useNav } from '@/nav/Navigator'; +import { useBackStep, useNav } from '@/nav/Navigator'; import { newIdempotencyKey } from '@/api/http'; import { SeyarMascot } from '@/mascots/SeyarMascot'; import type { SeyarMood } from '@/mascots/seyar'; @@ -74,6 +74,9 @@ export function QuizScreen({ lessonId, nodeId }: { lessonId?: number; nodeId?: s // پشتِ هم درست؛ برای «سه تا پشتِ هم!» (حسِ پیشرفت وسطِ آزمون، نه فقط آخرش). const [combo, setCombo] = useState(0); useGateHold(phase.kind === 'loading'); + // دکمه‌ی برگشتِ گوشی وسطِ تمرین همان «X» است: اول می‌پرسد، بی‌صدا بیرون نمی‌اندازد. برگه‌ی باز خودش قدمِ + // برگشتِ جداگانه دارد، پس برگشتِ دوم فقط برگه را می‌بندد. + useBackStep(phase.kind === 'playing' && !confirmExit, () => setConfirmExit(true)); // یک کلید برای هر سوال و یکی برای پایانِ درس؛ تکرارِ درخواست دوبار ثبت نمی‌شود. const answerKeys = useRef(new Map()); @@ -440,8 +443,10 @@ function HeartsRow({ hearts }: { hearts: Hearts | null }) { ); } - const max = hearts?.maxHearts ?? 5; - const current = hearts?.currentHearts ?? max; + // وضعیتِ قلب نرسید: پنج قلبِ پُرِ ساختگی نشان نمی‌دهیم؛ سرور با هر جواب عددِ واقعی را برمی‌گرداند. + if (!hearts) return null; + const max = hearts.maxHearts; + const current = hearts.currentHearts; return (
{Array.from({ length: max }, (_, i) => (