From 0a7cda31bfe64986fb34788e71868ccd59bc1fad Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Sun, 2 Mar 2025 12:10:16 +0100 Subject: [PATCH] feat(post): when attempting to reply, alert reply or thread was deleted or removed --- src/components/post-desktop/post-desktop.tsx | 18 +++++++++++++----- src/components/post-mobile/post-mobile.tsx | 18 +++++++++++++----- src/views/post/post.tsx | 15 +++------------ 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/components/post-desktop/post-desktop.tsx b/src/components/post-desktop/post-desktop.tsx index 47497c29..15c3e271 100644 --- a/src/components/post-desktop/post-desktop.tsx +++ b/src/components/post-desktop/post-desktop.tsx @@ -76,6 +76,18 @@ const PostInfo = ({ openReplyModal, post, postReplyCount = 0, roles, isHidden }: const { hidden } = useHide(post); + const onReplyModalClick = () => { + deleted + ? isReply + ? alert(t('this_reply_was_deleted')) + : alert(t('this_thread_was_deleted')) + : removed + ? isReply + ? alert(t('this_reply_was_removed')) + : alert(t('this_thread_was_removed')) + : openReplyModal && openReplyModal(cid, postCid, subplebbitAddress); + }; + return (
{isHidden ? parentCid && : } @@ -160,11 +172,7 @@ const PostInfo = ({ openReplyModal, post, postReplyCount = 0, roles, isHidden }: !cid && e.preventDefault()}> c/ - openReplyModal && !(deleted || removed) && openReplyModal(cid, postCid, subplebbitAddress)} - > + {shortCid} diff --git a/src/components/post-mobile/post-mobile.tsx b/src/components/post-mobile/post-mobile.tsx index 5a891e00..d2837924 100644 --- a/src/components/post-mobile/post-mobile.tsx +++ b/src/components/post-mobile/post-mobile.tsx @@ -57,6 +57,18 @@ const PostInfoAndMedia = ({ openReplyModal, post, postReplyCount = 0, roles }: P const { hidden } = useHide(post); + const onReplyModalClick = () => { + deleted + ? isReply + ? alert(t('this_reply_was_deleted')) + : alert(t('this_thread_was_deleted')) + : removed + ? isReply + ? alert(t('this_reply_was_removed')) + : alert(t('this_thread_was_removed')) + : openReplyModal && openReplyModal(cid, postCid, subplebbitAddress); + }; + return ( <>
@@ -152,11 +164,7 @@ const PostInfoAndMedia = ({ openReplyModal, post, postReplyCount = 0, roles }: P !cid && e.preventDefault()}> c/ - openReplyModal && !(deleted || removed) && openReplyModal(cid, postCid, subplebbitAddress)} - > + {shortCid.slice(0, -4)} diff --git a/src/views/post/post.tsx b/src/views/post/post.tsx index 6e46d9bf..0ed84059 100644 --- a/src/views/post/post.tsx +++ b/src/views/post/post.tsx @@ -30,14 +30,6 @@ export const Post = ({ post, showAllReplies = false, showReplies = true, openRep const subplebbit = useSubplebbit({ subplebbitAddress: post?.subplebbitAddress }); const isMobile = useIsMobile(); - const { deleted, locked, removed } = post || {}; - const isThreadClosed = deleted || locked || removed; - - const { t } = useTranslation(); - if (isThreadClosed) { - openReplyModal = () => alert(t('thread_closed_alert')); - } - let comment = post; // handle pending mod or author edit @@ -72,7 +64,7 @@ const PostPage = () => { const subplebbit = useSubplebbit({ subplebbitAddress }); const { createdAt, description, rules, shortAddress, suggested, title } = subplebbit; - const { activeCid, threadCid, closeModal, openReplyModal, showReplyModal, scrollY, subplebbitAddress: postSubplebbitAddress } = useReplyModal(); + const { activeCid, threadCid, closeModal, showReplyModal, scrollY, subplebbitAddress: postSubplebbitAddress } = useReplyModal(); const comment = useComment({ commentCid }); @@ -85,8 +77,7 @@ const PostPage = () => { post = comment; } - const { error, deleted, locked, removed, replyCount } = post || {}; - const isThreadClosed = deleted || locked || removed; + const { error, replyCount } = post || {}; useEffect(() => { window.scrollTo(0, 0); @@ -128,7 +119,7 @@ const PostPage = () => { ) : isInRulesView ? ( ) : ( - alert(t('thread_closed_alert')) : openReplyModal} /> + )}
);