mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(post): when attempting to reply, alert reply or thread was deleted or removed
This commit is contained in:
@@ -76,6 +76,18 @@ const PostInfo = ({ openReplyModal, post, postReplyCount = 0, roles, isHidden }:
|
|||||||
|
|
||||||
const { hidden } = useHide(post);
|
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 (
|
return (
|
||||||
<div className={styles.postInfo}>
|
<div className={styles.postInfo}>
|
||||||
{isHidden ? parentCid && <span className={styles.hiddenReplyEditMenuSpacer} /> : <EditMenu post={post} />}
|
{isHidden ? parentCid && <span className={styles.hiddenReplyEditMenuSpacer} /> : <EditMenu post={post} />}
|
||||||
@@ -160,11 +172,7 @@ const PostInfo = ({ openReplyModal, post, postReplyCount = 0, roles, isHidden }:
|
|||||||
<Link to={`/p/${subplebbitAddress}/c/${cid}`} className={styles.linkToPost} title={t('link_to_post')} onClick={(e) => !cid && e.preventDefault()}>
|
<Link to={`/p/${subplebbitAddress}/c/${cid}`} className={styles.linkToPost} title={t('link_to_post')} onClick={(e) => !cid && e.preventDefault()}>
|
||||||
c/
|
c/
|
||||||
</Link>
|
</Link>
|
||||||
<span
|
<span className={styles.replyToPost} title={t('reply_to_post')} onMouseDown={onReplyModalClick}>
|
||||||
className={styles.replyToPost}
|
|
||||||
title={t('reply_to_post')}
|
|
||||||
onMouseDown={() => openReplyModal && !(deleted || removed) && openReplyModal(cid, postCid, subplebbitAddress)}
|
|
||||||
>
|
|
||||||
{shortCid}
|
{shortCid}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -57,6 +57,18 @@ const PostInfoAndMedia = ({ openReplyModal, post, postReplyCount = 0, roles }: P
|
|||||||
|
|
||||||
const { hidden } = useHide(post);
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.postInfo}>
|
<div className={styles.postInfo}>
|
||||||
@@ -152,11 +164,7 @@ const PostInfoAndMedia = ({ openReplyModal, post, postReplyCount = 0, roles }: P
|
|||||||
<Link to={`/p/${subplebbitAddress}/c/${cid}`} className={styles.linkToPost} title={t('link_to_post')} onClick={(e) => !cid && e.preventDefault()}>
|
<Link to={`/p/${subplebbitAddress}/c/${cid}`} className={styles.linkToPost} title={t('link_to_post')} onClick={(e) => !cid && e.preventDefault()}>
|
||||||
c/
|
c/
|
||||||
</Link>
|
</Link>
|
||||||
<span
|
<span className={styles.replyToPost} title={t('reply_to_post')} onMouseDown={onReplyModalClick}>
|
||||||
className={styles.replyToPost}
|
|
||||||
title={t('reply_to_post')}
|
|
||||||
onMouseDown={() => openReplyModal && !(deleted || removed) && openReplyModal(cid, postCid, subplebbitAddress)}
|
|
||||||
>
|
|
||||||
{shortCid.slice(0, -4)}
|
{shortCid.slice(0, -4)}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
+3
-12
@@ -30,14 +30,6 @@ export const Post = ({ post, showAllReplies = false, showReplies = true, openRep
|
|||||||
const subplebbit = useSubplebbit({ subplebbitAddress: post?.subplebbitAddress });
|
const subplebbit = useSubplebbit({ subplebbitAddress: post?.subplebbitAddress });
|
||||||
const isMobile = useIsMobile();
|
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;
|
let comment = post;
|
||||||
|
|
||||||
// handle pending mod or author edit
|
// handle pending mod or author edit
|
||||||
@@ -72,7 +64,7 @@ const PostPage = () => {
|
|||||||
const subplebbit = useSubplebbit({ subplebbitAddress });
|
const subplebbit = useSubplebbit({ subplebbitAddress });
|
||||||
const { createdAt, description, rules, shortAddress, suggested, title } = subplebbit;
|
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 });
|
const comment = useComment({ commentCid });
|
||||||
|
|
||||||
@@ -85,8 +77,7 @@ const PostPage = () => {
|
|||||||
post = comment;
|
post = comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { error, deleted, locked, removed, replyCount } = post || {};
|
const { error, replyCount } = post || {};
|
||||||
const isThreadClosed = deleted || locked || removed;
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
@@ -128,7 +119,7 @@ const PostPage = () => {
|
|||||||
) : isInRulesView ? (
|
) : isInRulesView ? (
|
||||||
<SubplebbitRules createdAt={createdAt} rules={rules} subplebbitAddress={subplebbitAddress} />
|
<SubplebbitRules createdAt={createdAt} rules={rules} subplebbitAddress={subplebbitAddress} />
|
||||||
) : (
|
) : (
|
||||||
<Post post={post} showAllReplies={true} openReplyModal={isThreadClosed ? () => alert(t('thread_closed_alert')) : openReplyModal} />
|
<Post post={post} showAllReplies={true} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user