fix(post): deleted or removed replies should not be collapsed if edit reason is provided

This commit is contained in:
Tom (plebeius.eth)
2024-09-21 12:59:16 +02:00
parent d3af6c2a44
commit 994c667819
2 changed files with 9 additions and 9 deletions
+5 -5
View File
@@ -46,7 +46,7 @@ const useShowOmittedReplies = create<ShowOmittedRepliesState>((set) => ({
const PostInfo = ({ openReplyModal, post, postReplyCount = 0, roles, isHidden }: PostProps) => { const PostInfo = ({ openReplyModal, post, postReplyCount = 0, roles, isHidden }: PostProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { author, cid, deleted, locked, pinned, parentCid, postCid, removed, shortCid, state, subplebbitAddress, timestamp } = post || {}; const { author, cid, deleted, locked, pinned, parentCid, postCid, reason, removed, shortCid, state, subplebbitAddress, timestamp } = post || {};
const title = post?.title?.trim(); const title = post?.title?.trim();
const replies = useReplies(post); const replies = useReplies(post);
const { address, shortAddress } = author || {}; const { address, shortAddress } = author || {};
@@ -77,7 +77,7 @@ const PostInfo = ({ openReplyModal, post, postReplyCount = 0, roles, isHidden }:
return ( return (
<div className={styles.postInfo}> <div className={styles.postInfo}>
{!isHidden && <EditMenu post={post} />} {!isHidden && <EditMenu post={post} />}
<span className={(hidden || removed || deleted) && parentCid && styles.postDesktopHidden}> <span className={(hidden || ((removed || deleted) && !reason)) && parentCid && styles.postDesktopHidden}>
{title && {title &&
(title.length <= 75 ? ( (title.length <= 75 ? (
<span className={styles.subject}>{title} </span> <span className={styles.subject}>{title} </span>
@@ -290,7 +290,7 @@ const PostMessage = ({ post }: PostProps) => {
return ( return (
<blockquote className={`${styles.postMessage} ${isRules && styles.rulesMessage}`}> <blockquote className={`${styles.postMessage} ${isRules && styles.rulesMessage}`}>
{isReply && state !== 'failed' && isReplyingToReply && <ReplyQuotePreview isQuotelinkReply={true} quotelinkReply={quotelinkReply} />} {isReply && state !== 'failed' && isReplyingToReply && !(deleted || removed) && <ReplyQuotePreview isQuotelinkReply={true} quotelinkReply={quotelinkReply} />}
{removed ? ( {removed ? (
reason ? ( reason ? (
<> <>
@@ -381,7 +381,7 @@ const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => {
post = editedComment; post = editedComment;
} }
const { author, cid, deleted, link, postCid, removed, subplebbitAddress } = post || {}; const { author, cid, deleted, link, postCid, reason, 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 });
@@ -391,7 +391,7 @@ const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => {
<div className={`${styles.reply} ${isRouteLinkToReply && styles.highlight}`} data-cid={cid} data-author-address={author?.shortAddress} data-post-cid={postCid}> <div className={`${styles.reply} ${isRouteLinkToReply && styles.highlight}`} data-cid={cid} data-author-address={author?.shortAddress} 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 || removed || deleted) && <PostMessage post={post} />} {!hidden && (!(removed || deleted) || ((removed || deleted) && reason)) && <PostMessage post={post} />}
</div> </div>
</div> </div>
); );
+4 -4
View File
@@ -25,7 +25,7 @@ import _ from 'lodash';
const PostInfoAndMedia = ({ openReplyModal, post, postReplyCount = 0, roles }: PostProps) => { const PostInfoAndMedia = ({ openReplyModal, post, postReplyCount = 0, roles }: PostProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { author, cid, deleted, link, locked, parentCid, pinned, postCid, removed, shortCid, state, subplebbitAddress, timestamp } = post || {}; const { author, cid, deleted, link, locked, parentCid, pinned, postCid, reason, removed, shortCid, state, subplebbitAddress, timestamp } = post || {};
const title = post?.title?.trim(); const title = post?.title?.trim();
const { isDescription, isRules } = post || {}; // custom properties, not from api const { isDescription, isRules } = post || {}; // custom properties, not from api
const { address, shortAddress } = author || {}; const { address, shortAddress } = author || {};
@@ -61,7 +61,7 @@ const PostInfoAndMedia = ({ openReplyModal, post, postReplyCount = 0, roles }: P
<> <>
<div className={styles.postInfo}> <div className={styles.postInfo}>
<PostMenuMobile post={post} /> <PostMenuMobile post={post} />
<span className={(hidden || deleted || removed) && parentCid && styles.postDesktopHidden}> <span className={(hidden || ((removed || deleted) && !reason)) && parentCid && styles.postDesktopHidden}>
<span className={styles.nameBlock}> <span className={styles.nameBlock}>
<span className={`${styles.name} ${(isDescription || isRules || authorRole) && !(deleted || removed) && styles.capcodeMod}`}> <span className={`${styles.name} ${(isDescription || isRules || authorRole) && !(deleted || removed) && styles.capcodeMod}`}>
{removed ? ( {removed ? (
@@ -307,7 +307,7 @@ const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => {
if (editedComment) { if (editedComment) {
post = editedComment; post = editedComment;
} }
const { author, cid, deleted, postCid, removed, subplebbitAddress } = post || {}; const { author, cid, deleted, postCid, reason, 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 });
@@ -321,7 +321,7 @@ const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => {
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 && !deleted && !removed && <PostMessageMobile post={post} />} {!hidden && (!(removed || deleted) || ((removed || deleted) && reason)) && <PostMessageMobile post={post} />}
<ReplyBacklinks post={reply} /> <ReplyBacklinks post={reply} />
</div> </div>
</div> </div>