style(post): collapse reply if it's deleted or removed

This commit is contained in:
Tom (plebeius.eth)
2024-09-18 16:38:19 +02:00
parent d5dcedf3bd
commit 41c8f9dff8
3 changed files with 30 additions and 26 deletions
+4 -4
View File
@@ -202,7 +202,7 @@ const PostInfo = ({ openReplyModal, post, postReplyCount = 0, roles, isHidden }:
</span> </span>
)} )}
</span> </span>
<PostMenuDesktop post={post} /> {!(removed || deleted) && <PostMenuDesktop post={post} />}
{cid && {cid &&
parentCid && parentCid &&
replies && replies &&
@@ -298,7 +298,7 @@ const PostMessage = ({ post }: PostProps) => {
return ( return (
<blockquote className={`${styles.postMessage} ${isRules && styles.rulesMessage}`}> <blockquote className={`${styles.postMessage} ${isRules && styles.rulesMessage}`}>
{isReply && !(removed || deleted) && state !== 'failed' && isReplyingToReply && <ReplyQuotePreview isQuotelinkReply={true} quotelinkReply={quotelinkReply} />} {isReply && state !== 'failed' && isReplyingToReply && <ReplyQuotePreview isQuotelinkReply={true} quotelinkReply={quotelinkReply} />}
{removed ? ( {removed ? (
reason ? ( reason ? (
<> <>
@@ -397,14 +397,14 @@ const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => {
<div className={styles.replyDesktop}> <div className={styles.replyDesktop}>
<div className={styles.sideArrows}>{'>>'}</div> <div className={styles.sideArrows}>{'>>'}</div>
<div <div
className={`${styles.reply} ${isRouteLinkToReply && styles.highlight} ${hidden && styles.postDesktopHidden}`} className={`${styles.reply} ${isRouteLinkToReply && styles.highlight} ${(hidden || removed || deleted) && styles.postDesktopHidden}`}
data-cid={cid} data-cid={cid}
data-author-address={author?.shortAddress} data-author-address={author?.shortAddress}
data-post-cid={postCid} data-post-cid={postCid}
> >
<PostInfo openReplyModal={openReplyModal} post={post} postReplyCount={postReplyCount} roles={roles} /> <PostInfo openReplyModal={openReplyModal} post={post} postReplyCount={postReplyCount} roles={roles} />
{link && !hidden && !(deleted || removed) && isValidURL(link) && <PostMedia post={post} />} {link && !hidden && !(deleted || removed) && isValidURL(link) && <PostMedia post={post} />}
{!hidden && <PostMessage post={post} />} {!(hidden || removed || deleted) && <PostMessage post={post} />}
</div> </div>
</div> </div>
); );
@@ -130,7 +130,7 @@ const BlockBoardButton = ({ address }: { address: string }) => {
}; };
const PostMenuMobile = ({ post }: { post: Comment }) => { const PostMenuMobile = ({ post }: { post: Comment }) => {
const { author, cid, isDescription, isRules, link, parentCid, postCid, subplebbitAddress } = post || {}; const { author, cid, deleted, isDescription, isRules, link, parentCid, postCid, removed, subplebbitAddress } = post || {};
const { isAccountMod, isAccountCommentAuthor } = useEditCommentPrivileges({ commentAuthorAddress: author?.address, subplebbitAddress }); const { isAccountMod, isAccountCommentAuthor } = useEditCommentPrivileges({ commentAuthorAddress: author?.address, subplebbitAddress });
const commentMediaInfo = getCommentMediaInfo(post); const commentMediaInfo = getCommentMediaInfo(post);
const { thumbnail, type, url } = commentMediaInfo || {}; const { thumbnail, type, url } = commentMediaInfo || {};
@@ -159,6 +159,8 @@ const PostMenuMobile = ({ post }: { post: Comment }) => {
const isInBoardView = isBoardView(useLocation().pathname, useParams()); const isInBoardView = isBoardView(useLocation().pathname, useParams());
return ( return (
<>
{!(deleted || removed) && (
<> <>
<span className={styles.postMenuBtn} title='Post menu' onClick={handleMenuClick} ref={refs.setReference} {...getReferenceProps()}> <span className={styles.postMenuBtn} title='Post menu' onClick={handleMenuClick} ref={refs.setReference} {...getReferenceProps()}>
... ...
@@ -178,6 +180,8 @@ const PostMenuMobile = ({ post }: { post: Comment }) => {
</FloatingFocusManager>, </FloatingFocusManager>,
document.body, document.body,
)} )}
</>
)}
{(isAccountMod || isAccountCommentAuthor) && cid && ( {(isAccountMod || isAccountCommentAuthor) && cid && (
<span className={styles.checkbox}> <span className={styles.checkbox}>
<EditMenu post={post} /> <EditMenu post={post} />
+3 -3
View File
@@ -314,7 +314,7 @@ const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => {
if (editedComment) { if (editedComment) {
post = editedComment; post = editedComment;
} }
const { author, cid, postCid, subplebbitAddress } = post || {}; const { author, cid, deleted, postCid, removed, subplebbitAddress } = post || {};
const isRouteLinkToReply = useLocation().pathname.startsWith(`/p/${subplebbitAddress}/c/${cid}`); const isRouteLinkToReply = useLocation().pathname.startsWith(`/p/${subplebbitAddress}/c/${cid}`);
const { hidden } = useHide({ cid }); const { hidden } = useHide({ cid });
@@ -322,13 +322,13 @@ const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => {
<div className={styles.replyMobile}> <div className={styles.replyMobile}>
<div className={styles.reply}> <div className={styles.reply}>
<div <div
className={`${styles.replyContainer} ${isRouteLinkToReply && styles.highlight} ${hidden && styles.postDesktopHidden}`} className={`${styles.replyContainer} ${isRouteLinkToReply && styles.highlight} ${(hidden || deleted || removed) && styles.postDesktopHidden}`}
data-cid={cid} data-cid={cid}
data-author-address={author?.shortAddress} data-author-address={author?.shortAddress}
data-post-cid={postCid} data-post-cid={postCid}
> >
<PostInfoAndMedia openReplyModal={openReplyModal} post={post} postReplyCount={postReplyCount} roles={roles} /> <PostInfoAndMedia openReplyModal={openReplyModal} post={post} postReplyCount={postReplyCount} roles={roles} />
{!hidden && <PostMessageMobile post={post} />} {!hidden && !deleted && !removed && <PostMessageMobile post={post} />}
<ReplyBacklinks post={reply} /> <ReplyBacklinks post={reply} />
</div> </div>
</div> </div>