diff --git a/src/pages/primary/DiscussionsPage/ThreadCard.tsx b/src/pages/primary/DiscussionsPage/ThreadCard.tsx index 8c3af22..e06e420 100644 --- a/src/pages/primary/DiscussionsPage/ThreadCard.tsx +++ b/src/pages/primary/DiscussionsPage/ThreadCard.tsx @@ -21,9 +21,10 @@ interface ThreadCardProps { onThreadClick: () => void className?: string subtopics?: string[] // Available subtopics for this thread + primaryTopic?: string // The categorized primary topic (e.g., 'general', 'tech', etc.) } -export default function ThreadCard({ thread, onThreadClick, className, subtopics = [] }: ThreadCardProps) { +export default function ThreadCard({ thread, onThreadClick, className, subtopics = [], primaryTopic }: ThreadCardProps) { const { t } = useTranslation() const { isSmallScreen } = useScreenSize() @@ -31,9 +32,15 @@ export default function ThreadCard({ thread, onThreadClick, className, subtopics const titleTag = thread.tags.find(tag => tag[0] === 'title' && tag[1]) const title = titleTag?.[1] || t('Untitled') - // Extract topic from tags - const topicTag = thread.tags.find(tag => tag[0] === 't' && tag[1]) - const topic = topicTag?.[1] || 'general' + // Use the categorized primary topic if provided, otherwise extract from tags + const topic = primaryTopic || (() => { + const topicTag = thread.tags.find(tag => tag[0] === 't' && tag[1]) + const firstTag = topicTag?.[1] || 'general' + + // If the first tag is not a predefined topic, default to 'general' + const predefinedTopicIds = DISCUSSION_TOPICS.map(t => t.id) + return predefinedTopicIds.includes(firstTag) ? firstTag : 'general' + })() // Extract author and subject for readings threads const authorTag = thread.tags.find(tag => tag[0] === 'author' && tag[1]) diff --git a/src/pages/primary/DiscussionsPage/index.tsx b/src/pages/primary/DiscussionsPage/index.tsx index e6d8a62..adca337 100644 --- a/src/pages/primary/DiscussionsPage/index.tsx +++ b/src/pages/primary/DiscussionsPage/index.tsx @@ -827,6 +827,7 @@ const DiscussionsPage = forwardRef((_, ref) => { key={event.id} thread={event} subtopics={threadSubtopics} + primaryTopic={entry?.categorizedTopic} onThreadClick={() => { push(toNote(event)) }} @@ -851,6 +852,7 @@ const DiscussionsPage = forwardRef((_, ref) => { key={event.id} thread={event} subtopics={threadSubtopics} + primaryTopic={entry?.categorizedTopic} onThreadClick={() => { push(toNote(event)) }}