From dcd970c70646c6f4a7a4e928d64bdac98a7064da Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Wed, 18 Sep 2024 12:37:39 +0200 Subject: [PATCH] fix replycount of description post --- src/components/board-buttons/board-buttons.tsx | 6 ++++-- .../subplebbit-description/subplebbit-description.tsx | 5 +++-- src/views/board/board.tsx | 1 + src/views/post/post.tsx | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/board-buttons/board-buttons.tsx b/src/components/board-buttons/board-buttons.tsx index a168115a..c1da6aed 100644 --- a/src/components/board-buttons/board-buttons.tsx +++ b/src/components/board-buttons/board-buttons.tsx @@ -1,6 +1,6 @@ import { useTranslation } from 'react-i18next'; import { Link, useLocation, useNavigate, useParams } from 'react-router-dom'; -import { useAccountComment, useComment, useSubscribe } from '@plebbit/plebbit-react-hooks'; +import { useAccountComment, useComment, useSubplebbit, useSubscribe } from '@plebbit/plebbit-react-hooks'; import { isAllView, isCatalogView, isDescriptionView, isPendingPostView, isPostPageView, isSubscriptionsView } from '../../lib/utils/view-utils'; import useCatalogStyleStore from '../../stores/use-catalog-style-store'; import useFeedResetStore from '../../stores/use-feed-reset-store'; @@ -291,10 +291,12 @@ const PostPageStats = () => { const isInDescriptionView = isDescriptionView(location.pathname, params); const comment = useComment({ commentCid: params?.commentCid }); + const subplebbit = useSubplebbit({ subplebbitAddress: params?.subplebbitAddress }); + const descriptionReplyCount = location?.pathname.startsWith('/p/all/') ? 0 : subplebbit?.rules?.length > 0 ? 1 : 0; const { closed, pinned, replyCount } = comment || {}; const linkCount = useCountLinksInReplies(comment); - const displayReplyCount = replyCount !== undefined ? replyCount.toString() : isInDescriptionView ? 1 : '?'; + const displayReplyCount = replyCount !== undefined ? replyCount.toString() : isInDescriptionView ? descriptionReplyCount : '?'; const replyCountTooltip = replyCount !== undefined || isInDescriptionView ? _.capitalize(t('replies')) : t('loading'); return ( diff --git a/src/components/subplebbit-description/subplebbit-description.tsx b/src/components/subplebbit-description/subplebbit-description.tsx index 93805647..d392f351 100644 --- a/src/components/subplebbit-description/subplebbit-description.tsx +++ b/src/components/subplebbit-description/subplebbit-description.tsx @@ -8,12 +8,13 @@ interface DescriptionPostProps { avatarUrl?: string; createdAt: number; description: string; + replyCount: number; shortAddress: string; subplebbitAddress: string | undefined; title: string; } -const SubplebbitDescription = ({ avatarUrl, createdAt, description, shortAddress, subplebbitAddress, title }: DescriptionPostProps) => { +const SubplebbitDescription = ({ avatarUrl, createdAt, description, replyCount, shortAddress, subplebbitAddress, title }: DescriptionPostProps) => { const { t } = useTranslation(); const location = useLocation(); const isInAllView = isAllView(location.pathname, useParams()); @@ -26,7 +27,7 @@ const SubplebbitDescription = ({ avatarUrl, createdAt, description, shortAddress author: { displayName: `## ${t('board_mods')}` }, content: isInAllView ? multisubMetadata?.description : description, link: avatarUrl, - replyCount: 1, + replyCount, title: t('welcome_to_board', { board: isInAllView ? multisubMetadata?.title : title || `p/${shortAddress}`, interpolation: { escapeValue: false }, diff --git a/src/views/board/board.tsx b/src/views/board/board.tsx index 748139f3..0d22f879 100644 --- a/src/views/board/board.tsx +++ b/src/views/board/board.tsx @@ -186,6 +186,7 @@ const Board = () => { subplebbitAddress={subplebbitAddress} createdAt={createdAt} description={description} + replyCount={isInAllView ? 0 : rules?.length > 0 ? 1 : 0} shortAddress={shortAddress} title={title} /> diff --git a/src/views/post/post.tsx b/src/views/post/post.tsx index f62a4a85..6b2308bd 100644 --- a/src/views/post/post.tsx +++ b/src/views/post/post.tsx @@ -109,6 +109,7 @@ const PostPage = () => { avatarUrl={suggested?.avatarUrl} createdAt={createdAt} description={description} + replyCount={location.pathname.startsWith('/p/all/') ? 0 : rules?.length > 0 ? 1 : 0} subplebbitAddress={subplebbitAddress} shortAddress={shortAddress} title={title}