From 604ebac472b51d1d95bef7f2b126075b7edeb221 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Thu, 8 Jun 2023 21:41:27 +0200 Subject: [PATCH] Update EditLabel.jsx --- src/components/EditLabel.jsx | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/components/EditLabel.jsx b/src/components/EditLabel.jsx index af872279..ef1159e8 100644 --- a/src/components/EditLabel.jsx +++ b/src/components/EditLabel.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useState } from "react"; import { useComment, useEditedComment } from "@plebbit/plebbit-react-hooks"; import { Link } from "react-router-dom"; import OriginalCommentModal from "./modals/OriginalCommentModal"; @@ -6,33 +6,41 @@ import getDate from "../utils/getDate"; const EditLabel = ({ commentCid, className }) => { - const [isOriginalCommentModalOpen, setIsOriginalCommentModalOpen] = React.useState(false); + const [isOriginalCommentModalOpen, setIsOriginalCommentModalOpen] = useState(false); const comment = useComment({commentCid}); const timestamp = getDate(comment.edit?.timestamp); const {state: editedCommentState, editedComment} = useEditedComment({comment}); - + return ( <> setIsOriginalCommentModalOpen(false)} comment={comment}/> - {editedComment && ( + {editedComment || comment.edit ? ( <>
- {editedCommentState === 'succeeded' && ( + {comment.removed ? ( <> - (Edited at {timestamp}, setIsOriginalCommentModalOpen(true) - }>show original) + (This post has been removed) - )} - {editedCommentState === 'pending' && ("(Pending Edit)")} - {editedCommentState === 'failed' && ("(Failed Edit)")} + ) : ( + <> + {comment.edit ? ( + <> + (Edited at {timestamp}, setIsOriginalCommentModalOpen(true) + }>show original) + + ) : null} + {editedCommentState === 'pending' && ("(Pending edit)")} + {editedCommentState === 'failed' && ("(Failed edit)")} + + )} - )} + ) : null} ); };