feat(feed): show account comments instantly in the feed once published, instead of waiting for the feed to update

This commit is contained in:
Tom (plebeius.eth)
2024-08-03 13:21:09 +02:00
parent 2ab71978a7
commit 8598d1056e
4 changed files with 139 additions and 68 deletions
+5 -2
View File
@@ -1,7 +1,7 @@
import { useEffect, useRef, useState } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import { Link, useLocation, useParams } from 'react-router-dom';
import { Comment, useAccount, useAuthorAvatar, useComment, useEditedComment } from '@plebbit/plebbit-react-hooks';
import { Comment, useAccount, useAccountComments, useAuthorAvatar, useComment, useEditedComment } from '@plebbit/plebbit-react-hooks';
import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js';
import styles from '../../views/post/post.module.css';
import { getCommentMediaInfo, getDisplayMediaInfoType, getHasThumbnail } from '../../lib/utils/media-utils';
@@ -383,6 +383,9 @@ const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies
const visiblelinksCount = useCountLinksInReplies(post, 5);
const totalLinksCount = useCountLinksInReplies(post);
const replyCount = replies?.length;
const { accountComments } = useAccountComments();
const isPostInAccountComments = accountComments?.find((comment) => comment.cid === cid);
const repliesCount = pinned ? replyCount : replyCount - 5;
const linksCount = pinned ? totalLinksCount : totalLinksCount - visiblelinksCount;
const { showOmittedReplies, setShowOmittedReplies } = useShowOmittedReplies();
@@ -439,7 +442,7 @@ const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies
)}
</span>
)}
{post?.replyCount === undefined && !isInPendingPostView && (
{post?.replyCount === undefined && !isPostInAccountComments && !isInPendingPostView && (
<span className={styles.loadingString}>
<LoadingEllipsis string={t('loading_comments')} />
</span>