From 15af37bbc92363ff2f338b974baedc3a1d43dac3 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Wed, 9 Sep 2026 18:23:14 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=99=88=20=EC=A3=BC=EC=A0=9C=20?= =?UTF-8?q?=ED=83=AD=EC=9D=B4=20=ED=81=90=EB=A0=88=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=EC=B9=B8=20=EB=8C=80=EC=8B=A0=20=EC=8B=A4=EC=A0=9C=20=EA=B8=B0?= =?UTF-8?q?=EB=A1=9D=EC=9D=84=20=EC=9D=BD=EB=8A=94=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CPU 가상화 주제에 글을 게시했는데 홈 탭은 「아직 공개된 기록이 없습니다」였다. 축을 쓰지 않는 주제의 목록을 상세의 featuredCases 로 만들었는데, 그 칸은 작성자가 주제마다 손으로 골라 두는 값이라 대부분 비어 있다. 게다가 Case 만 담아서, 게시한 것이 동작 원리면 애초에 담기지 않는다 — 주제 목록의 recordCount 는 1 인데 탭은 0 이라고 말했다. 주제 화면이 하는 것과 같이 기록 자체를 읽는다. 받는 중에는 「없습니다」라고 말하지 않는다. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01PTnWufiY9ATv57egkKKVAV --- .../public/components/home-topic-tabs.tsx | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/features/tech-log/presentation/public/components/home-topic-tabs.tsx b/src/features/tech-log/presentation/public/components/home-topic-tabs.tsx index b832cb1..4b40f00 100644 --- a/src/features/tech-log/presentation/public/components/home-topic-tabs.tsx +++ b/src/features/tech-log/presentation/public/components/home-topic-tabs.tsx @@ -1,9 +1,10 @@ -import { useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { Link } from "react-router-dom"; import { useApplication } from "../../../../../presentation/providers/application-provider.tsx"; import { TECH_LOG_FEATURE_ID } from "../../../application/tech-log-feature-input.ts"; import type { + PublicRecord, PublicTopic, PublicTopicDetail, } from "../../../application/ports/public-content-queries.ts"; @@ -38,6 +39,16 @@ export function HomeTopicTabs({ [firstDetail.slug]: firstDetail, }); const [failedSlug, setFailedSlug] = useState(null); + /* + 축을 쓰지 않는 주제의 기록. + + 처음에는 상세의 `featuredCases` 를 썼는데 그것은 작성자가 주제마다 손으로 골라 두는 값이라 + 대부분 비어 있다 — CPU 가상화에 글을 게시해도 홈 탭은 「아직 공개된 기록이 없습니다」였다. + 게다가 그 칸은 Case 만 담아서, 게시한 것이 동작 원리면 애초에 담기지 않는다. + + 주제 화면이 하는 것과 같이 기록 자체를 읽는다. + */ + const [records, setRecords] = useState>>>({}); const buttons = useRef>([]); const slugs = topics.map((topic) => topic.slug); const active = topics.find((topic) => topic.slug === activeSlug) ?? topics[0]; @@ -50,6 +61,7 @@ export function HomeTopicTabs({ buttons.current[slugs.indexOf(slug)]?.focus(); }); } + loadRecordsIfNeeded(slug, details[slug]); if (details[slug]) return; void publicContent .getTopicDetail(slug) @@ -59,6 +71,7 @@ export function HomeTopicTabs({ return; } setDetails((loaded) => ({ ...loaded, [slug]: detail })); + loadRecordsIfNeeded(slug, detail); }) /* 받지 못했다는 사실을 그 자리에 남긴다. 예전에 홈이 두 읽기를 `Promise.all` 로 묶었을 때는 @@ -67,6 +80,22 @@ export function HomeTopicTabs({ .catch(() => setFailedSlug(slug)); } + /* 견줄 축이 없는 주제만 기록을 따로 받는다. 축이 있으면 축이 곧 목록이다. */ + function loadRecordsIfNeeded(slug: string, detail: PublicTopicDetail | undefined) { + if (!detail || detail.variants.length > 1) return; + if (records[slug]) return; + void publicContent + .listRecords({ topic: slug }) + .then((found) => setRecords((loaded) => ({ ...loaded, [slug]: found }))) + .catch(() => setRecords((loaded) => ({ ...loaded, [slug]: [] }))); + } + + useEffect(() => { + loadRecordsIfNeeded(firstDetail.slug, firstDetail); + // 첫 주제는 상세가 이미 와 있으므로 여기서 한 번만 본다. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [firstDetail]); + function onKeyDown(event: React.KeyboardEvent) { if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return; event.preventDefault(); @@ -91,10 +120,10 @@ export function HomeTopicTabs({ title: variant.title, line: variant.conclusion || variant.summary, })) - : detail.featuredCases.map((record) => ({ + : (records[active.slug] ?? []).map((record) => ({ path: record.path, title: record.title, - line: record.summary || record.note, + line: record.summary, })) : []; const comparing = (detail?.variants.length ?? 0) > 1; @@ -179,7 +208,7 @@ export function HomeTopicTabs({ ))} - ) : detail ? ( + ) : detail && (comparing || records[active.slug]) ? (

{`${active.name}에는 아직 공개된 기록이 없습니다.`}