From 30947a67f075e643b1f90372431d11cf95b64b7d Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 10 Jun 2023 14:31:25 +0200 Subject: [PATCH] add editedComment conditional to EditLabel --- src/components/EditLabel.jsx | 60 +++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/src/components/EditLabel.jsx b/src/components/EditLabel.jsx index ef1159e8..0ccd2f3b 100644 --- a/src/components/EditLabel.jsx +++ b/src/components/EditLabel.jsx @@ -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 ( <> setIsOriginalCommentModalOpen(false)} - comment={comment}/> - {editedComment || comment.edit ? ( + isOpen={isOriginalCommentModalOpen} + closeModal={() => setIsOriginalCommentModalOpen(false)} + comment={comment}/> + {comment.edit && ( <>
- {comment.removed ? ( - <> - (This post has been removed) - - ) : ( - <> - {comment.edit ? ( - <> - (Edited at {timestamp}, setIsOriginalCommentModalOpen(true) - }>show original) - - ) : null} - {editedCommentState === 'pending' && ("(Pending edit)")} - {editedCommentState === 'failed' && ("(Failed edit)")} - - )} + (Edited at {timestamp}, setIsOriginalCommentModalOpen(true) + }>show original) + + + )} + {((editedCommentState === 'pending' || editedCommentState === 'failed') && conditionsString) ? ( + <> +
+ + ({editedCommentState === 'pending' ? 'Pending' : 'Failed'} {conditionsString}) ) : null}