From aa11d09fc3f4f6ff1858fdbb1dea312d7a409b24 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Mon, 19 Oct 2026 00:46:03 +0900 Subject: [PATCH] #428 --- frontend/src/pages/tags/TagHistoryPage.tsx | 39 +++++++++++----------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/frontend/src/pages/tags/TagHistoryPage.tsx b/frontend/src/pages/tags/TagHistoryPage.tsx index 5271e55..a9ce066 100644 --- a/frontend/src/pages/tags/TagHistoryPage.tsx +++ b/frontend/src/pages/tags/TagHistoryPage.tsx @@ -19,7 +19,7 @@ import { postsKeys, tagsKeys, wikiKeys } from '@/lib/queryKeys' import { fetchTagChanges } from '@/lib/tags' import { useClientBehaviourSettings } from '@/lib/useClientBehaviourSettings' import { useUITranslation } from '@/lib/useUITranslation' -import { localisedDateString } from '@/lib/utils' +import { cn, localisedDateString } from '@/lib/utils' import type { FC, ReactNode } from 'react' @@ -144,7 +144,7 @@ const renderDiff = ( const TagVersionRows = ({ change, children }: { change: TagVersion - children: (primary: ReactNode, toggle: ReactNode) => ReactNode }) => { + children: (primary: ReactNode) => ReactNode }) => { const locale = useLocale () const language = localeLanguage (locale) const { message, label } = useUITranslation ('history') @@ -169,29 +169,23 @@ const TagVersionRows = ({ change, children }: { : ((change.nameChanges != null && change.name.prev === change.name.current) ? current : legacyName (change.name.prev)) const missingNameRecord = current?.name == null && previous?.name == null - const [expansion, setExpansion] = useState ({ language, expanded: missingNameRecord }) - const expanded = expansion.language === language ? expansion.expanded : missingNameRecord const otherLanguages = [...new Set ([...Object.keys (names), ...nameChanges.map (entry => entry.languageCode)])] .filter (code => code !== language).sort () const otherChanges = nameChanges.filter (entry => entry.languageCode !== language) + const initiallyExpanded = missingNameRecord || otherChanges.length > 0 + const [expansion, setExpansion] = useState ({ language, expanded: initiallyExpanded }) + const expanded = expansion.language === language ? expansion.expanded : initiallyExpanded const rowIds = otherLanguages.map ((_, index) => `${panelId}-${index}`) const primaryEqual = (prev: TagNameSnapshot | null, next: TagNameSnapshot | null) => prev?.name === next?.name && prev?.autoGenerated === next?.autoGenerated const primary = missingNameRecord - ? ( - <> - {change.currentNameReference != null && ( -
- {renderPrimaryName (change.currentNameReference, language, label)} - {label ('nameChanges.currentReference')} -
)} - ) + ? null : renderDiff ({ current, prev: previous }, snapshot => renderPrimaryName (snapshot, language, label), primaryEqual) const toggle = otherLanguages.length > 0 && ( -
+