From b13ea69aad205946c23a51bc5f8159f5f46841b7 Mon Sep 17 00:00:00 2001 From: Christopher Gurnee Date: Wed, 3 Nov 2021 11:26:31 -0400 Subject: [PATCH] Show comments manually restored by mods --- src/pages/thread/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pages/thread/index.js b/src/pages/thread/index.js index 870b5ec..7556e3d 100644 --- a/src/pages/thread/index.js +++ b/src/pages/thread/index.js @@ -66,6 +66,7 @@ class Thread extends React.Component { missingIds.add(comment.parent_id) } }); + pushshiftComments = undefined missingIds.clear() // Get all the comments from reddit @@ -82,7 +83,7 @@ class Thread extends React.Component { // When a parent comment is missing from pushshift, use the reddit comment instead comment.parent_id = comment.parent_id.substring(3) comment.link_id = comment.link_id.substring(3) - pushshiftComments.push(comment) + pushshiftCommentLookup.set(comment.id, comment) } else { // Replace pushshift score with reddit (it's usually more accurate) pushshiftComment.score = comment.score @@ -93,12 +94,17 @@ class Thread extends React.Component { removed.add(comment.id) } else if (isDeleted(comment.body)) { deleted.add(comment.id) + } else if (pushshiftComment !== undefined && isRemoved(pushshiftComment.body)) { + // If it's deleted in pushshift, but later restored by a mod, use the restored + comment.parent_id = comment.parent_id.substring(3) + comment.link_id = comment.link_id.substring(3) + pushshiftCommentLookup.set(comment.id, comment) } }) this.props.global.setSuccess() this.setState({ - pushshiftComments, + pushshiftComments: Array.from(pushshiftCommentLookup.values()), removed, deleted, loadingComments: false