fix(board-buttons): use useComment in PostPageStats so reply count shows on direct thread URLs

This commit is contained in:
plebeius
2026-02-24 16:42:39 +08:00
parent 0e1421fff7
commit ce8159f2ea
@@ -1,7 +1,6 @@
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom'; import { Link, useLocation, useNavigate, useParams } from 'react-router-dom';
import { useAccountComment, useSubscribe } from '@plebbit/plebbit-react-hooks'; import { useAccountComment, useComment, useSubscribe } from '@plebbit/plebbit-react-hooks';
import useSubplebbitsPagesStore from '@plebbit/plebbit-react-hooks/dist/stores/subplebbits-pages';
import { isAllView, isCatalogView, isModView, isModQueueView, isPendingPostView, isPostPageView, isSubscriptionsView } from '../../lib/utils/view-utils'; import { isAllView, isCatalogView, isModView, isModQueueView, isPendingPostView, isPostPageView, isSubscriptionsView } from '../../lib/utils/view-utils';
import { useDirectories } from '../../hooks/use-directories'; import { useDirectories } from '../../hooks/use-directories';
import { getBoardPath, isDirectoryBoard } from '../../lib/utils/route-utils'; import { getBoardPath, isDirectoryBoard } from '../../lib/utils/route-utils';
@@ -458,11 +457,14 @@ export const MobileBoardButtons = () => {
export const PostPageStats = () => { export const PostPageStats = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const params = useParams(); const params = useParams();
const commentCid = params?.commentCid as string | undefined;
const comment = useSubplebbitsPagesStore((state) => state.comments[params?.commentCid as string]); const comment = useComment({ commentCid });
const postCid = comment?.parentCid ?? commentCid;
const post = useComment({ commentCid: postCid });
const { closed, pinned, replyCount } = comment || {}; const { closed, pinned, replyCount } = post || {};
const linkCount = useCountLinksInReplies(comment); const linkCount = useCountLinksInReplies(post);
const displayReplyCount = replyCount !== undefined ? replyCount.toString() : '?'; const displayReplyCount = replyCount !== undefined ? replyCount.toString() : '?';
const replyCountTooltip = replyCount !== undefined ? capitalize(t('replies')) : t('loading'); const replyCountTooltip = replyCount !== undefined ? capitalize(t('replies')) : t('loading');