mirror of
https://github.com/gurnec/removeddit.git
synced 2026-03-11 08:54:27 +00:00
Fix bug where rich diff wasn't display by default
Instead, the original was displayed even when the edit was available.
This bug was introduced:
* in 7c935ab for all edited posts, and
* when rich diffs where first added, but only in cases where a perent
comment was edited, and that parent was loaded by clicking `parent`
from a top-level permalinked comment.
This commit is contained in:
parent
1b874bef66
commit
9134f3f569
3 changed files with 21 additions and 19 deletions
|
|
@ -62,21 +62,22 @@ const Post = (props) => {
|
||||||
const innerHTML = Array(editedModes.length)
|
const innerHTML = Array(editedModes.length)
|
||||||
if (props.removed && isRemoved(props.selftext)) {
|
if (props.removed && isRemoved(props.selftext)) {
|
||||||
if (!hasOwnProperty.call(props, 'retrieved_utc') && !hasOwnProperty.call(props, 'retrieved_on') || !hasOwnProperty.call(props, 'created_utc')) {
|
if (!hasOwnProperty.call(props, 'retrieved_utc') && !hasOwnProperty.call(props, 'retrieved_on') || !hasOwnProperty.call(props, 'created_utc')) {
|
||||||
innerHTML[editedModes.orig] = '<p>[removed too quickly to be archived]</p>'
|
innerHTML[editedModes.dfault] = '<p>[removed too quickly to be archived]</p>'
|
||||||
} else {
|
} else {
|
||||||
const retrieved = hasOwnProperty.call(props, 'retrieved_utc') ? props.retrieved_utc : props.retrieved_on;
|
const retrieved = hasOwnProperty.call(props, 'retrieved_utc') ? props.retrieved_utc : props.retrieved_on;
|
||||||
innerHTML[editedModes.orig] = `<p>[removed within ${prettyTimeDiff(retrieved - props.created_utc)}]</p>`
|
innerHTML[editedModes.dfault] = `<p>[removed within ${prettyTimeDiff(retrieved - props.created_utc)}]</p>`
|
||||||
}
|
}
|
||||||
} else if (props.selftext && (props.is_self || !isDeleted(props.selftext))) {
|
} else if (props.selftext && (props.is_self || !isDeleted(props.selftext))) {
|
||||||
innerHTML[editedModes.orig] = parse(props.selftext)
|
|
||||||
if (hasOwnProperty.call(props, 'edited_selftext')) {
|
if (hasOwnProperty.call(props, 'edited_selftext')) {
|
||||||
|
innerHTML[editedModes.orig] = parse(props.selftext)
|
||||||
innerHTML[editedModes.edited] = parse(props.edited_selftext)
|
innerHTML[editedModes.edited] = parse(props.edited_selftext)
|
||||||
innerHTML[editedModes.rich] = Diff.execute(innerHTML[editedModes.orig], innerHTML[editedModes.edited])
|
innerHTML[editedModes.dfault] = Diff.execute(innerHTML[editedModes.orig], innerHTML[editedModes.edited])
|
||||||
}
|
} else
|
||||||
|
innerHTML[editedModes.dfault] = parse(props.selftext)
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
const [editedMode, setEditedMode] = useState(innerHTML[editedModes.rich] ? editedModes.rich : editedModes.orig)
|
const [editedMode, setEditedMode] = useState(editedModes.dfault)
|
||||||
|
|
||||||
const totalComments = <div className='total-comments'>
|
const totalComments = <div className='total-comments'>
|
||||||
<Link to={props.permalink} replace={props.isLocFullPost}>{props.num_comments} comments</Link>
|
<Link to={props.permalink} replace={props.isLocFullPost}>{props.num_comments} comments</Link>
|
||||||
|
|
|
||||||
|
|
@ -23,29 +23,30 @@ const Comment = (props) => {
|
||||||
const innerHTML = Array(editedModes.length)
|
const innerHTML = Array(editedModes.length)
|
||||||
if (props.removed && isRemoved(props.body)) {
|
if (props.removed && isRemoved(props.body)) {
|
||||||
if (!hasOwnProperty.call(props, 'retrieved_utc') && !hasOwnProperty.call(props, 'retrieved_on') || !hasOwnProperty.call(props, 'created_utc')) {
|
if (!hasOwnProperty.call(props, 'retrieved_utc') && !hasOwnProperty.call(props, 'retrieved_on') || !hasOwnProperty.call(props, 'created_utc')) {
|
||||||
innerHTML[editedModes.orig] = '<p>[removed too quickly to be archived]</p>'
|
innerHTML[editedModes.dfault] = '<p>[removed too quickly to be archived]</p>'
|
||||||
} else if (props.created_utc < 1627776000) { // Aug 1 2021
|
} else if (props.created_utc < 1627776000) { // Aug 1 2021
|
||||||
const retrieved = hasOwnProperty.call(props, 'retrieved_utc') ? props.retrieved_utc : props.retrieved_on;
|
const retrieved = hasOwnProperty.call(props, 'retrieved_utc') ? props.retrieved_utc : props.retrieved_on;
|
||||||
innerHTML[editedModes.orig] = `<p>[removed within ${prettyTimeDiff(retrieved - props.created_utc)}]</p>`
|
innerHTML[editedModes.dfault] = `<p>[removed within ${prettyTimeDiff(retrieved - props.created_utc)}]</p>`
|
||||||
}
|
}
|
||||||
// After around Aug 1 2021, Pushshift began updating comments from Reddit after around
|
// After around Aug 1 2021, Pushshift began updating comments from Reddit after around
|
||||||
// 24-48 hours, including removing(?) comments that were removed from Reddit. The presence
|
// 24-48 hours, including removing(?) comments that were removed from Reddit. The presence
|
||||||
// of either retrieved_utc or retrieved_on can currently be used to test for this behaviour.
|
// of either retrieved_utc or retrieved_on can currently be used to test for this behaviour.
|
||||||
else if (hasOwnProperty.call(props, 'retrieved_utc')) {
|
else if (hasOwnProperty.call(props, 'retrieved_utc')) {
|
||||||
innerHTML[editedModes.orig] = `<p>[removed within ${prettyTimeDiff(props.retrieved_utc - props.created_utc)}]</p>`
|
innerHTML[editedModes.dfault] = `<p>[removed within ${prettyTimeDiff(props.retrieved_utc - props.created_utc)}]</p>`
|
||||||
} else {
|
} else {
|
||||||
innerHTML[editedModes.orig] = `<p>[either removed too quickly, or <a href='https://www.reddit.com/r/pushshift/comments/pgzdav/the_api_now_appears_to_rewrite_nearly_all/'>removed(?) from archive</a> after ${prettyTimeDiff(props.retrieved_on - props.created_utc, true)}]</p>`
|
innerHTML[editedModes.dfault] = `<p>[either removed too quickly, or <a href='https://www.reddit.com/r/pushshift/comments/pgzdav/the_api_now_appears_to_rewrite_nearly_all/'>removed(?) from archive</a> after ${prettyTimeDiff(props.retrieved_on - props.created_utc, true)}]</p>`
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
innerHTML[editedModes.orig] = parse(props.body)
|
|
||||||
if (hasOwnProperty.call(props, 'edited_body')) {
|
if (hasOwnProperty.call(props, 'edited_body')) {
|
||||||
|
innerHTML[editedModes.orig] = parse(props.body)
|
||||||
innerHTML[editedModes.edited] = parse(props.edited_body)
|
innerHTML[editedModes.edited] = parse(props.edited_body)
|
||||||
innerHTML[editedModes.rich] = Diff.execute(innerHTML[editedModes.orig], innerHTML[editedModes.edited])
|
innerHTML[editedModes.dfault] = Diff.execute(innerHTML[editedModes.orig], innerHTML[editedModes.edited])
|
||||||
}
|
} else
|
||||||
|
innerHTML[editedModes.dfault] = parse(props.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
const [collapsed, setCollapsed] = useState(false)
|
const [collapsed, setCollapsed] = useState(false)
|
||||||
const [editedMode, setEditedMode] = useState(innerHTML[editedModes.rich] ? editedModes.rich : editedModes.orig)
|
const [editedMode, setEditedMode] = useState(editedModes.dfault)
|
||||||
const permalink = `/r/${props.subreddit}/comments/${props.link_id}/_/${props.id}/`
|
const permalink = `/r/${props.subreddit}/comments/${props.link_id}/_/${props.id}/`
|
||||||
const parentlink = props.parent_id == props.link_id ? undefined : (
|
const parentlink = props.parent_id == props.link_id ? undefined : (
|
||||||
props.depth == 0 ?
|
props.depth == 0 ?
|
||||||
|
|
|
||||||
10
src/utils.js
10
src/utils.js
|
|
@ -118,13 +118,13 @@ export const showRemovedAndDeleted = comment => comment.removed === true || comm
|
||||||
|
|
||||||
// Edited text display modes
|
// Edited text display modes
|
||||||
export const editedModes = {
|
export const editedModes = {
|
||||||
orig: 0,
|
dfault: 0, // diff mode if it's been edited, otherwise same as orig
|
||||||
edited: 1,
|
orig: 1,
|
||||||
rich: 2,
|
edited: 2,
|
||||||
length: 3
|
length: 3
|
||||||
}
|
}
|
||||||
export const editedTitles = [
|
export const editedTitles = [
|
||||||
|
'Edits are highlighted; click to change',
|
||||||
'The first archived edit is shown; click to change',
|
'The first archived edit is shown; click to change',
|
||||||
'The most recent edit is shown; click to change',
|
'The most recent edit is shown; click to change'
|
||||||
'Edits are highlighted; click to change'
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue