mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
add editedComment conditional to EditLabel
This commit is contained in:
@@ -11,33 +11,51 @@ const EditLabel = ({ commentCid, className }) => {
|
|||||||
const timestamp = getDate(comment.edit?.timestamp);
|
const timestamp = getDate(comment.edit?.timestamp);
|
||||||
const {state: editedCommentState, editedComment} = useEditedComment({comment});
|
const {state: editedCommentState, editedComment} = useEditedComment({comment});
|
||||||
|
|
||||||
|
|
||||||
|
const conditionsCheck = () => {
|
||||||
|
let conditions = [];
|
||||||
|
|
||||||
|
if (editedComment?.removed && !comment.removed) {
|
||||||
|
conditions.push("removal");
|
||||||
|
}
|
||||||
|
if (editedComment?.edit && !comment.edit) {
|
||||||
|
conditions.push("edit");
|
||||||
|
}
|
||||||
|
if (editedComment?.locked && !comment.locked) {
|
||||||
|
conditions.push("lock");
|
||||||
|
}
|
||||||
|
if (editedComment?.pinned && !comment.pinned) {
|
||||||
|
conditions.push("sticky");
|
||||||
|
}
|
||||||
|
|
||||||
|
return conditions.length > 0 ? conditions.join(', ') : null;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const conditionsString = conditionsCheck();
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<OriginalCommentModal
|
<OriginalCommentModal
|
||||||
isOpen={isOriginalCommentModalOpen}
|
isOpen={isOriginalCommentModalOpen}
|
||||||
closeModal={() => setIsOriginalCommentModalOpen(false)}
|
closeModal={() => setIsOriginalCommentModalOpen(false)}
|
||||||
comment={comment}/>
|
comment={comment}/>
|
||||||
{editedComment || comment.edit ? (
|
{comment.edit && (
|
||||||
<>
|
<>
|
||||||
<br />
|
<br />
|
||||||
<span className={className}>
|
<span className={className}>
|
||||||
{comment.removed ? (
|
(Edited at {timestamp}, <Link className="ttl-link" onClick={
|
||||||
<>
|
() => setIsOriginalCommentModalOpen(true)
|
||||||
(This post has been removed)
|
}>show original</Link>)
|
||||||
</>
|
</span>
|
||||||
) : (
|
</>
|
||||||
<>
|
)}
|
||||||
{comment.edit ? (
|
{((editedCommentState === 'pending' || editedCommentState === 'failed') && conditionsString) ? (
|
||||||
<>
|
<>
|
||||||
(Edited at {timestamp}, <Link className="ttl-link" onClick={
|
<br />
|
||||||
() => setIsOriginalCommentModalOpen(true)
|
<span className={className}>
|
||||||
}>show original</Link>)
|
({editedCommentState === 'pending' ? 'Pending' : 'Failed'} {conditionsString})
|
||||||
</>
|
|
||||||
) : null}
|
|
||||||
{editedCommentState === 'pending' && ("(Pending edit)")}
|
|
||||||
{editedCommentState === 'failed' && ("(Failed edit)")}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</span>
|
</span>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
Reference in New Issue
Block a user