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
-1
View File
@@ -721,7 +721,6 @@ const All = () => {
if (thread.removed) { if (thread.removed) {
thread.content = "[removed]"; thread.content = "[removed]";
thread.link = undefined; thread.link = undefined;
thread.title = "[removed]";
} }
}; };
const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {}; const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {};
-1
View File
@@ -1636,7 +1636,6 @@ const Board = () => {
if (thread.removed) { if (thread.removed) {
thread.content = "[removed]"; thread.content = "[removed]";
thread.link = undefined; thread.link = undefined;
thread.title = "[removed]";
} }
}; };
const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {}; const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {};
-1
View File
@@ -729,7 +729,6 @@ const Subscriptions = () => {
if (thread.removed) { if (thread.removed) {
thread.content = "[removed]"; thread.content = "[removed]";
thread.link = undefined; thread.link = undefined;
thread.title = "[removed]";
} }
}; };
const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {}; const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {};
+27 -2
View File
@@ -56,6 +56,7 @@ const Thread = () => {
setChallengesArray, setChallengesArray,
defaultSubplebbits, defaultSubplebbits,
editedComment, editedComment,
editedComments,
setIsAuthorDelete, setIsAuthorDelete,
setIsAuthorEdit, setIsAuthorEdit,
setIsCaptchaOpen, setIsCaptchaOpen,
@@ -134,9 +135,10 @@ const Thread = () => {
useAnonMode(selectedThread, anonymousMode && executeAnonMode); useAnonMode(selectedThread, anonymousMode && executeAnonMode);
const comment = useComment({commentCid: selectedThread}); const originalComment = useComment({commentCid: selectedThread});
const [comment, setComment] = useState(originalComment);
const { subplebbitAddress, threadCid } = useParams(); const { subplebbitAddress, threadCid } = useParams();
const subplebbit = useSubplebbit({subplebbitAddress: comment.subplebbitAddress}); const subplebbit = useSubplebbit({subplebbitAddress: originalComment.subplebbitAddress});
const selectedAddress = subplebbit.address; const selectedAddress = subplebbit.address;
const stateString = useStateString(comment); const stateString = useStateString(comment);
@@ -145,6 +147,22 @@ const Thread = () => {
const fallbackImgUrl = "assets/filedeleted-res.gif"; 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) => { const handleThumbnailClick = (index, type) => {
switch(type) { switch(type) {
case 'thread': case 'thread':
@@ -1272,6 +1290,13 @@ const Thread = () => {
</div> </div>
{comment.replyCount === undefined ? <PostLoader /> : null} {comment.replyCount === undefined ? <PostLoader /> : null}
{sortedReplies.map((reply, index) => { {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 replyMediaInfo = getCommentMediaInfo(reply);
const fallbackImgUrl = "assets/filedeleted-res.gif"; const fallbackImgUrl = "assets/filedeleted-res.gif";
const shortParentCid = findShortParentCid(reply.parentCid, comment); const shortParentCid = findShortParentCid(reply.parentCid, comment);