revert, replyCount should come from api

This commit is contained in:
Tom (plebeius.eth)
2024-07-07 14:36:14 +02:00
parent 44e518a3ad
commit ff72365151
5 changed files with 22 additions and 30 deletions
@@ -1,8 +1,6 @@
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom';
import { useAccountComment, useComment, useSubscribe } from '@plebbit/plebbit-react-hooks';
import { flattenCommentsPages } from '@plebbit/plebbit-react-hooks/dist/lib/utils';
import { isAllView, isCatalogView, isDescriptionView, isPendingPostView, isPostPageView, isRulesView, isSubscriptionsView } from '../../lib/utils/view-utils';
import useCatalogStyleStore from '../../stores/use-catalog-style-store';
import useFeedResetStore from '../../stores/use-feed-reset-store';
@@ -12,7 +10,6 @@ import CatalogFilters from '../../views/catalog/catalog-filters/';
import styles from './board-buttons.module.css';
import Tooltip from '../tooltip';
import useCountLinksInReplies from '../../hooks/use-count-links-in-replies';
import useReplyCount from '../../hooks/use-reply-count';
interface BoardButtonsProps {
address?: string | undefined;
@@ -232,10 +229,8 @@ const PostPageStats = () => {
const isInRulesView = isRulesView(location.pathname, params);
const comment = useComment({ commentCid: params?.commentCid });
const { closed, pinned } = comment || {};
const { closed, pinned, replyCount } = comment || {};
const linkCount = useCountLinksInReplies(comment);
const replyCount = useReplyCount(comment);
return (
<span>
+19 -6
View File
@@ -12,7 +12,6 @@ import useEditCommentPrivileges from '../../hooks/use-author-privileges';
import useCountLinksInReplies from '../../hooks/use-count-links-in-replies';
import useFetchGifFirstFrame from '../../hooks/use-fetch-gif-first-frame';
import useHide from '../../hooks/use-hide';
import useReplyCount from '../../hooks/use-reply-count';
import useWindowWidth from '../../hooks/use-window-width';
import PostMenuDesktop from '../post-desktop/post-menu-desktop';
import styles from './catalog-row.module.css';
@@ -96,8 +95,25 @@ export const CatalogPostMedia = ({ commentMediaInfo, isOutOfFeed, linkWidth, lin
const CatalogPost = ({ post }: { post: Comment }) => {
const { t } = useTranslation();
const { author, cid, content, isDescription, isRules, lastChildCid, link, linkHeight, linkWidth, locked, pinned, spoiler, subplebbitAddress, timestamp, title } =
post || {};
const {
author,
cid,
content,
isDescription,
isRules,
lastChildCid,
link,
linkHeight,
linkWidth,
locked,
pinned,
replyCount,
spoiler,
subplebbitAddress,
timestamp,
title,
} = post || {};
const linkCount = useCountLinksInReplies(post);
const commentMediaInfo = getCommentMediaInfo(post);
const hasThumbnail = getHasThumbnail(commentMediaInfo, link);
const { hidden } = useHide({ cid });
@@ -107,9 +123,6 @@ const CatalogPost = ({ post }: { post: Comment }) => {
const postLink = isInAllView && isDescription ? `/p/all/description` : `/p/${subplebbitAddress}/${isDescription ? 'description' : isRules ? 'rules' : `c/${cid}`}`;
const linkCount = useCountLinksInReplies(post);
const replyCount = useReplyCount(post);
const threadIcons = (
<div className={styles.threadIcons}>
{pinned && <span className={styles.stickyIcon} title={t('sticky')} />}
+1 -3
View File
@@ -13,7 +13,6 @@ import useEditCommentPrivileges from '../../hooks/use-author-privileges';
import useCountLinksInReplies from '../../hooks/use-count-links-in-replies';
import useHide from '../../hooks/use-hide';
import useReplies from '../../hooks/use-replies';
import useReplyCount from '../../hooks/use-reply-count';
import useStateString from '../../hooks/use-state-string';
import CommentMedia from '../comment-media';
import EditMenu from '../edit-menu/edit-menu';
@@ -339,7 +338,7 @@ const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => {
const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies = true }: PostProps) => {
const { t } = useTranslation();
const { author, cid, content, link, pinned, postCid, subplebbitAddress } = post || {};
const { author, cid, content, link, pinned, postCid, replyCount, subplebbitAddress } = post || {};
const { isDescription, isRules } = post || {}; // custom properties, not from api
const params = useParams();
const location = useLocation();
@@ -350,7 +349,6 @@ const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies
const isHidden = hidden && !isInPostPageView;
const replies = useReplies(post);
const replyCount = useReplyCount(post);
const visiblelinksCount = useCountLinksInReplies(post, 5);
const totalLinksCount = useCountLinksInReplies(post);
const repliesCount = pinned ? replyCount : replyCount - 5;
+1 -3
View File
@@ -11,7 +11,6 @@ import useAuthorAddressClick from '../../hooks/use-author-address-click';
import useCountLinksInReplies from '../../hooks/use-count-links-in-replies';
import useHide from '../../hooks/use-hide';
import useReplies from '../../hooks/use-replies';
import useReplyCount from '../../hooks/use-reply-count';
import useStateString from '../../hooks/use-state-string';
import CommentMedia from '../comment-media';
import LoadingEllipsis from '../loading-ellipsis';
@@ -276,9 +275,8 @@ const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => {
const PostMobile = ({ openReplyModal, post, roles, showAllReplies, showReplies = true }: PostProps) => {
const { t } = useTranslation();
const { author, cid, content, pinned, postCid, subplebbitAddress } = post || {};
const { author, cid, content, pinned, postCid, replyCount, subplebbitAddress } = post || {};
const { isDescription, isRules } = post || {}; // custom properties, not from api
const replyCount = useReplyCount(post);
const params = useParams();
const location = useLocation();
const isInAllView = isAllView(location.pathname, params);