diff --git a/src/index.html b/src/index.html
index a45acea..de6c404 100644
--- a/src/index.html
+++ b/src/index.html
@@ -53,7 +53,7 @@ __)|_(_||||||(_|| ) |/\|(_|_) | \ |(_)| )|_
`':::_:' -- '' -'-' `':_::::'`
-->
-
+
Removeddit
diff --git a/src/js/App.js b/src/js/App.js
index b6d6aa9..2848cec 100644
--- a/src/js/App.js
+++ b/src/js/App.js
@@ -8,10 +8,10 @@ import {
import Header from 'components/Header'
import { About, Thread, Subreddit } from 'pages'
-export default props => (
+export default () => (
-
+
diff --git a/src/js/api/pushshift/index.js b/src/js/api/pushshift/index.js
index 3b2a317..8d259af 100644
--- a/src/js/api/pushshift/index.js
+++ b/src/js/api/pushshift/index.js
@@ -1,7 +1,7 @@
import { json, toBase10, toBase36, chunk, flatten } from 'utils'
const baseURL = 'https://elastic.pushshift.io'
-const threadURL = `${baseURL}/rs/submissions/_search?source=`
+const postURL = `${baseURL}/rs/submissions/_search?source=`
const commentURL = `${baseURL}/rc/comments/_search?source=`
const commentIDsURL = 'https://api.pushshift.io/reddit/submission/comment_ids/'
@@ -11,7 +11,7 @@ export const getCommentIDs = threadID => (
.then(results => results.data)
)
-export const getThread = threadID => {
+export const getPost = threadID => {
const elasticQuery = {
query: {
term: {
@@ -21,12 +21,12 @@ export const getThread = threadID => {
}
return (
- fetch(threadURL + JSON.stringify(elasticQuery))
+ fetch(postURL + JSON.stringify(elasticQuery))
.then(json)
.then(jsonData => jsonData.hits.hits[0]._source)
- .then(thread => {
- thread.id = toBase36(thread.id)
- return thread
+ .then(post => {
+ post.id = toBase36(post.id)
+ return post
})
)
}
@@ -55,7 +55,7 @@ const fetchComments = commentIDs => {
comment._source.id = toBase36(comment._id)
if (!comment._source.parent_id) {
- console.log('MISSING PARENT ID')
+ console.error('MISSING PARENT ID')
}
comment._source.parent_id = toBase36(comment._source.parent_id)
diff --git a/src/js/api/reddit/comment.js b/src/js/api/reddit/comment.js
index 7b6350f..5ace18f 100644
--- a/src/js/api/reddit/comment.js
+++ b/src/js/api/reddit/comment.js
@@ -98,3 +98,8 @@ const handleMoreChildren = (threadID, commentID, results) => (
const debug = results => {
console.log(JSON.parse(JSON.stringify(results)))
}
+
+// GET REMAINING COMMENTS
+export const getRemainingComments = commentIDs => {
+
+}
diff --git a/src/js/components/ThreadHead.js b/src/js/components/Post.js
similarity index 100%
rename from src/js/components/ThreadHead.js
rename to src/js/components/Post.js
diff --git a/src/js/index.js b/src/js/index.js
index 6ff3500..7a71d0f 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -1,36 +1,17 @@
-// import React from 'react'
-// import ReactDOM from 'react-dom'
-// import { Provider } from 'react-redux'
-// import { store } from 'state'
-// import App from 'App'
-// // import { setStatusLoading } from 'state'
+import React from 'react'
+import ReactDOM from 'react-dom'
+import { Provider } from 'react-redux'
+import { store } from 'state'
+import App from 'App'
+// import { setStatusLoading } from 'state'
-// import '../sass/main.sass'
+import '../sass/main.sass'
-// ReactDOM.render(
-//
-//
-// ,
-// document.getElementById('app')
-// )
+ReactDOM.render(
+
+
+ ,
+ document.getElementById('app')
+)
// store.dispatch(setStatusLoading('hi'))
-
-import { getCommentIDs } from 'api/reddit'
-import { getCommentIDs as getAllCommentIDs } from 'api/pushshift'
-
-import { difference } from './utils/index'
-
-
-Promise.all([
- getAllCommentIDs('6z1hch'),
- getCommentIDs('TwoXChromosomes', '6z1hch'),
-])
- .then(resp => console.log(resp[1].length, difference(resp[0], resp[1])))
-
-
-// getCommentIDs('6z1hch')
-
-// getThread('6z1hch').then(console.log)
-// getComments(['dmt88s6', 'dmtqxj8', 'dmt1euz']).then(console.log)
-// .then(ids => console.log(unique(ids)))
diff --git a/src/js/pages/Thread.js b/src/js/pages/Thread.js
index b2615b6..e7daa0c 100644
--- a/src/js/pages/Thread.js
+++ b/src/js/pages/Thread.js
@@ -1,23 +1,24 @@
import React from 'react'
-import ThreadHead from 'components/ThreadHead'
+import Post from 'components/Post'
import CommentSection from 'components/CommentSection'
import {
- getThread,
+ getPost,
getCommentIDs,
- extractHead,
-} from 'reddit'
+} from 'api/reddit'
import {
- getThread as getRemovedThread,
+ getPost as getRemovedPost,
getCommentIDs as getAllCommentIDs,
-} from 'pushshift'
+ getComments as getRemovedComments,
+} from 'api/pushshift'
import { isDeleted } from 'utils'
+import { difference } from '../utils/index'
export default class Thread extends React.Component {
constructor(props) {
super(props)
this.state = {
- thread: {},
+ post: {},
comments: [],
}
}
@@ -25,44 +26,42 @@ export default class Thread extends React.Component {
componentDidMount() {
const { subreddit, threadID } = this.props.match.params
console.timeEnd('scripts loaded')
- let pushshiftCommentIDs
Promise.all([
-
-
- // OUTDATED
// Get thread from reddit
- // getThread(subreddit, threadID)
- // .then(extractHead)
- // .then(thread => {
- // this.setState({ thread })
-
- // // Fetch the thread from pushshift if it was deleted/removed
- // if (isDeleted(thread.selftext)) {
- // getRemovedThread(threadID)
- // .then(removedThread => {
- // removedThread.removed = true
- // this.setState({ thread: removedThread })
- // })
- // }
- // })
- // // Get comment ids from reddit
- // .then(() => getCommentIDs(subreddit, threadID)),
+ getPost(subreddit, threadID)
+ .then(post => {
+ this.setState({ post })
+ // Fetch the thread from pushshift if it was deleted/removed
+ if (isDeleted(post.selftext)) {
+ // getRemovedPost(threadID)
+ // .then(removedPost => {
+ // removedPost.removed = true
+ // this.setState({ post: removedPost })
+ // })
+ }
+ })
+ // Get comment ids from reddit
+ .then(() => getCommentIDs(subreddit, threadID)),
// Get comment ids from pushshift
- getAllCommentIDs(threadID)
- .then(commentIDs => { pushshiftCommentIDs = commentIDs }),
+ getAllCommentIDs(threadID),
])
- .then(() => {
- // .then(console.log)
+ .then(results => {
+ const foundIDs = results[0]
+ const allIDs = results[1]
+
+ const removedIDs = difference(allIDs, foundIDs)
+ // Get removed comments from pushshift
+ return getRemovedComments(removedIDs)
})
}
render() {
return (
)
}