Update post.tsx

This commit is contained in:
Tom (plebeius.eth)
2025-03-07 11:29:04 +01:00
parent 99fdb90578
commit d8e4a4656e
+3 -4
View File
@@ -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 });