From ddb462b95e7c00fc81f28234d12ce3909ede7dc8 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Mon, 22 Jul 2024 16:10:59 +0200 Subject: [PATCH] fix(post): reply quote link couldn't render in posts with link and no content --- src/components/post-desktop/post-desktop.tsx | 4 +- src/components/post-mobile/post-mobile.tsx | 130 +++++++++--------- .../avatar-settings.module.css | 1 - 3 files changed, 66 insertions(+), 69 deletions(-) diff --git a/src/components/post-desktop/post-desktop.tsx b/src/components/post-desktop/post-desktop.tsx index c8e16445..1b73dfad 100644 --- a/src/components/post-desktop/post-desktop.tsx +++ b/src/components/post-desktop/post-desktop.tsx @@ -341,7 +341,7 @@ const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => { post = editedComment; } - const { author, cid, content, link, postCid, subplebbitAddress } = post || {}; + const { author, cid, link, postCid, subplebbitAddress } = post || {}; const isRouteLinkToReply = useLocation().pathname.startsWith(`/p/${subplebbitAddress}/c/${cid}`); const { hidden } = useHide({ cid }); @@ -356,7 +356,7 @@ const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => { > {link && !hidden && isValidURL(link) && } - {content && !hidden && } + {!hidden && } ); diff --git a/src/components/post-mobile/post-mobile.tsx b/src/components/post-mobile/post-mobile.tsx index 322f0860..4d735d41 100644 --- a/src/components/post-mobile/post-mobile.tsx +++ b/src/components/post-mobile/post-mobile.tsx @@ -185,72 +185,70 @@ const PostMessageMobile = ({ post }: PostProps) => { ); return ( - content && ( -
- {isReply && !(removed || deleted) && state !== 'failed' && isReplyingToReply && } - {removed ? ( +
+ {isReply && !(removed || deleted) && state !== 'failed' && isReplyingToReply && } + {removed ? ( + ({t('this_post_was_removed')})} + content={`${_.capitalize(t('reason'))}: "${reason}"`} + showTooltip={!!reason} + /> + ) : deleted ? ( + {t('user_deleted_this_post')}} content={reason && `${t('reason')}: ${reason}`} /> + ) : ( + <> + {!showOriginal && } + {edit && original?.content !== post?.content && ( + + {showOriginal && } +
+ {t('comment_edited_at_timestamp', { timestamp: getFormattedDate(edit?.timestamp), interpolation: { escapeValue: false } })}{' '} + {reason && <>{t('reason_reason', { reason: reason, interpolation: { escapeValue: false } })} } + {showOriginal ? ( + setShowOriginal(!showOriginal)} /> }} + /> + ) : ( + setShowOriginal(!showOriginal)} /> }} + /> + )} +
+ )} + + )} + {/* TODO: commentAuthor is not available outside of editedComment, update when available */} + {/* {banned && ( + +
+
({t('this_post_was_removed')})
} - content={`${_.capitalize(t('reason'))}: "${reason}"`} - showTooltip={!!reason} + children={`(${t('user_banned')})`} + content={`${t('ban_expires_at', { + address: subplebbitAddress && Plebbit.getShortAddress(subplebbitAddress), + timestamp: getFormattedDate(commentAuthor?.banExpiresAt), + interpolation: { escapeValue: false }, + })}${reason ? `. ${_.capitalize(t('reason'))}: "${reason}"` : ''}`} /> - ) : deleted ? ( - {t('user_deleted_this_post')}} content={reason && `${t('reason')}: ${reason}`} /> - ) : ( - <> - {!showOriginal && } - {edit && original?.content !== post?.content && ( - - {showOriginal && } -
- {t('comment_edited_at_timestamp', { timestamp: getFormattedDate(edit?.timestamp), interpolation: { escapeValue: false } })}{' '} - {reason && <>{t('reason_reason', { reason: reason, interpolation: { escapeValue: false } })} } - {showOriginal ? ( - setShowOriginal(!showOriginal)} /> }} - /> - ) : ( - setShowOriginal(!showOriginal)} /> }} - /> - )} -
- )} - - )} - {/* TODO: commentAuthor is not available outside of editedComment, update when available */} - {/* {banned && ( - -
-
- -
- )} */} - {!isReply && content.length > 1000 && !isInPostView && ( - -
- }} /> -
- )} - {!cid && state === 'pending' && stateString !== 'Failed' && ( - <> -
- {loadingString} - - )} -
- ) + + )} */} + {!isReply && content.length > 1000 && !isInPostView && ( + +
+ }} /> +
+ )} + {!cid && state === 'pending' && stateString !== 'Failed' && ( + <> +
+ {loadingString} + + )} +
); }; @@ -261,7 +259,7 @@ const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => { if (editedComment) { post = editedComment; } - const { author, cid, content, postCid, subplebbitAddress } = post || {}; + const { author, cid, postCid, subplebbitAddress } = post || {}; const isRouteLinkToReply = useLocation().pathname.startsWith(`/p/${subplebbitAddress}/c/${cid}`); const { hidden } = useHide({ cid }); @@ -275,7 +273,7 @@ const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => { data-post-cid={postCid} > - {content && !hidden && } + {!hidden && } diff --git a/src/components/settings-modal/avatar-settings/avatar-settings.module.css b/src/components/settings-modal/avatar-settings/avatar-settings.module.css index 163afba8..409947bb 100644 --- a/src/components/settings-modal/avatar-settings/avatar-settings.module.css +++ b/src/components/settings-modal/avatar-settings/avatar-settings.module.css @@ -4,7 +4,6 @@ border: 1px solid #aaa; background-color: var(--avatar-background-color, white); margin-left: 10px; - border-radius: 32px; overflow: hidden; }