update mod edit

This commit is contained in:
plebeius.eth
2023-09-16 21:10:38 +02:00
parent b6f21f0034
commit 43f63aa341
4 changed files with 27 additions and 5 deletions
+27 -2
View File
@@ -56,6 +56,7 @@ const Thread = () => {
setChallengesArray,
defaultSubplebbits,
editedComment,
editedComments,
setIsAuthorDelete,
setIsAuthorEdit,
setIsCaptchaOpen,
@@ -134,9 +135,10 @@ const Thread = () => {
useAnonMode(selectedThread, anonymousMode && executeAnonMode);
const comment = useComment({commentCid: selectedThread});
const originalComment = useComment({commentCid: selectedThread});
const [comment, setComment] = useState(originalComment);
const { subplebbitAddress, threadCid } = useParams();
const subplebbit = useSubplebbit({subplebbitAddress: comment.subplebbitAddress});
const subplebbit = useSubplebbit({subplebbitAddress: originalComment.subplebbitAddress});
const selectedAddress = subplebbit.address;
const stateString = useStateString(comment);
@@ -144,6 +146,22 @@ const Thread = () => {
const commentMediaInfo = getCommentMediaInfo(comment);
const fallbackImgUrl = "assets/filedeleted-res.gif";
useEffect(() => {
let updatedComment = { ...originalComment };
if (editedComments[originalComment.cid]) {
updatedComment = { ...originalComment, ...editedComments[originalComment.cid] };
if (updatedComment.removed) {
updatedComment.content = "[removed]";
updatedComment.link = undefined;
}
}
setComment(updatedComment);
}, [originalComment, editedComments]);
const handleThumbnailClick = (index, type) => {
switch(type) {
@@ -1272,6 +1290,13 @@ const Thread = () => {
</div>
{comment.replyCount === undefined ? <PostLoader /> : null}
{sortedReplies.map((reply, index) => {
if (editedComments[reply.cid]) {
reply = editedComments[reply.cid];
if (reply.removed) {
reply.content = "[removed]";
reply.link = undefined;
}
}
const replyMediaInfo = getCommentMediaInfo(reply);
const fallbackImgUrl = "assets/filedeleted-res.gif";
const shortParentCid = findShortParentCid(reply.parentCid, comment);