mirror of
https://github.com/plebbit/seedit.git
synced 2026-02-08 21:11:04 -05:00
fix(post): fix isInPostView including pending view
This commit is contained in:
@@ -18,7 +18,7 @@ interface PostProps {
|
||||
|
||||
const Post = ({ post, index }: PostProps) => {
|
||||
const {
|
||||
author: { shortAddress },
|
||||
author,
|
||||
cid,
|
||||
content,
|
||||
downvoteCount,
|
||||
@@ -27,7 +27,6 @@ const Post = ({ post, index }: PostProps) => {
|
||||
linkHeight,
|
||||
linkWidth,
|
||||
replyCount,
|
||||
spoiler,
|
||||
subplebbitAddress,
|
||||
timestamp,
|
||||
title,
|
||||
@@ -38,14 +37,15 @@ const Post = ({ post, index }: PostProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { isPendingView, isPostView } = useCurrentView();
|
||||
const [isInPostView, setIsInPostView] = useState(isPostView || isPendingView);
|
||||
const toggleExpanded = () => setIsInPostView(!isInPostView);
|
||||
const isInPostView = isPostView || isPendingView;
|
||||
const [isExpanded, setIsExpanded] = useState(isInPostView);
|
||||
const toggleExpanded = () => setIsExpanded(!isExpanded);
|
||||
|
||||
const commentMediaInfo = utils.getCommentMediaInfoMemoized(post);
|
||||
const hasThumbnail = utils.hasThumbnail(commentMediaInfo, link);
|
||||
const linkUrl = utils.getHostname(link);
|
||||
|
||||
const postAuthor = isPendingView ? account?.author?.shortAddress : shortAddress;
|
||||
const postAuthor = isPendingView ? account?.author?.shortAddress : author?.shortAddress;
|
||||
const postScore = upvoteCount === 0 && downvoteCount === 0 ? '•' : upvoteCount - downvoteCount || '•';
|
||||
const postTitleOrContent = (title?.length > 300 ? title?.slice(0, 300) + '...' : title) || (content?.length > 300 ? content?.slice(0, 300) + '...' : content);
|
||||
|
||||
@@ -106,7 +106,7 @@ const Post = ({ post, index }: PostProps) => {
|
||||
<ExpandButton
|
||||
commentMediaInfo={commentMediaInfo}
|
||||
content={content}
|
||||
expanded={isInPostView}
|
||||
expanded={isExpanded}
|
||||
hasThumbnail={hasThumbnail}
|
||||
link={link}
|
||||
toggleExpanded={toggleExpanded}
|
||||
@@ -114,7 +114,7 @@ const Post = ({ post, index }: PostProps) => {
|
||||
)}
|
||||
<p className={styles.tagline}>
|
||||
{t('post_submitted')} {utils.getFormattedTime(timestamp)} {t('post_by')}{' '}
|
||||
<Link className={styles.author} to={`u/${shortAddress}`} onClick={(e) => e.preventDefault()}>
|
||||
<Link className={styles.author} to={`u/${postAuthor}`} onClick={(e) => e.preventDefault()}>
|
||||
u/{postAuthor}
|
||||
</Link>
|
||||
{t('post_to')}
|
||||
@@ -123,11 +123,11 @@ const Post = ({ post, index }: PostProps) => {
|
||||
p/{subplebbit?.shortAddress}
|
||||
</Link>
|
||||
</p>
|
||||
<PostTools cid={cid} replyCount={replyCount} spoiler={spoiler} subplebbitAddress={subplebbitAddress} />
|
||||
<PostTools cid={cid} replyCount={replyCount} subplebbitAddress={subplebbitAddress} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Expando commentMediaInfo={commentMediaInfo} content={content} expanded={isInPostView} link={link} showContent={true} />
|
||||
<Expando commentMediaInfo={commentMediaInfo} content={content} expanded={isExpanded} link={link} showContent={true} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user