add editedComment conditional to EditLabel

This commit is contained in:
plebeius.eth
2023-06-10 14:31:25 +02:00
parent aa45e4c963
commit 30947a67f0
+39 -21
View File
@@ -11,33 +11,51 @@ const EditLabel = ({ commentCid, className }) => {
const timestamp = getDate(comment.edit?.timestamp);
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 (
<>
<OriginalCommentModal
isOpen={isOriginalCommentModalOpen}
closeModal={() => setIsOriginalCommentModalOpen(false)}
comment={comment}/>
{editedComment || comment.edit ? (
isOpen={isOriginalCommentModalOpen}
closeModal={() => setIsOriginalCommentModalOpen(false)}
comment={comment}/>
{comment.edit && (
<>
<br />
<span className={className}>
{comment.removed ? (
<>
(This post has been removed)
</>
) : (
<>
{comment.edit ? (
<>
(Edited at {timestamp}, <Link className="ttl-link" onClick={
() => setIsOriginalCommentModalOpen(true)
}>show original</Link>)
</>
) : null}
{editedCommentState === 'pending' && ("(Pending edit)")}
{editedCommentState === 'failed' && ("(Failed edit)")}
</>
)}
(Edited at {timestamp}, <Link className="ttl-link" onClick={
() => setIsOriginalCommentModalOpen(true)
}>show original</Link>)
</span>
</>
)}
{((editedCommentState === 'pending' || editedCommentState === 'failed') && conditionsString) ? (
<>
<br />
<span className={className}>
({editedCommentState === 'pending' ? 'Pending' : 'Failed'} {conditionsString})
</span>
</>
) : null}