From d8e4a4656e084c02e2c51bc1c02af8141f3d4d88 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Fri, 7 Mar 2025 11:29:04 +0100 Subject: [PATCH] Update post.tsx --- src/views/post/post.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/views/post/post.tsx b/src/views/post/post.tsx index 8a3fe8a0..e2cb3990 100644 --- a/src/views/post/post.tsx +++ b/src/views/post/post.tsx @@ -1,6 +1,6 @@ import { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; -import { Comment, Role, useComment, useEditedComment } from '@plebbit/plebbit-react-hooks'; +import { Comment, Role, useComment, useEditedComment, useSubplebbit } from '@plebbit/plebbit-react-hooks'; import useSubplebbitsStore from '@plebbit/plebbit-react-hooks/dist/stores/subplebbits'; import { useLocation, useParams } from 'react-router-dom'; import { isAllView, isDescriptionView, isRulesView } from '../../lib/utils/view-utils'; @@ -57,10 +57,9 @@ const PostPage = () => { const isInDescriptionView = isDescriptionView(location.pathname, params); const isInRulesView = isRulesView(location.pathname, params); - const subplebbit = useSubplebbitsStore((state) => state.subplebbits[subplebbitAddress as string]); - const { createdAt, description, rules, shortAddress, suggested, title } = subplebbit; - const comment = useComment({ commentCid }); + const subplebbit = useSubplebbit({ subplebbitAddress }); + const { createdAt, description, rules, shortAddress, suggested, title } = subplebbit || {}; // if the comment is a reply, return the post comment instead, then the reply will be highlighted in the thread const postComment = useComment({ commentCid: comment?.postCid });