mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(board-buttons): use useComment in PostPageStats so reply count shows on direct thread URLs
This commit is contained in:
@@ -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');
|
||||||
|
|||||||
Reference in New Issue
Block a user