From 043c80839c18d52e01ee7d9cc2d3d6647a8b34d4 Mon Sep 17 00:00:00 2001 From: Christopher Gurnee Date: Thu, 7 Oct 2021 00:23:33 +0000 Subject: [PATCH] Disable subreddit support --- src/api/removeddit/index.js | 22 ++-- src/index.js | 6 +- src/pages/common/Header.js | 3 +- src/pages/common/Post.js | 2 +- src/pages/subreddit/SubredditPagination.js | 50 +++---- src/pages/subreddit/SubredditSort.js | 42 +++--- src/pages/subreddit/index.js | 146 ++++++++++----------- 7 files changed, 134 insertions(+), 137 deletions(-) diff --git a/src/api/removeddit/index.js b/src/api/removeddit/index.js index 5c8751a..1240c3a 100644 --- a/src/api/removeddit/index.js +++ b/src/api/removeddit/index.js @@ -1,11 +1,11 @@ -const baseURL = 'http://unddit.com/api' - -export const getRemovedThreadIDs = (subreddit = '', page = 1) => { - if (subreddit.toLowerCase() === 'all') { - subreddit = '' - } - - return window.fetch(`${baseURL}/threads?subreddit=${subreddit}&page=${page - 1}`) - .then(response => response.json()) - .catch(() => { throw new Error('Could not get removed threads') }) -} +//const baseURL = 'http://unddit.com/api' +// +//export const getRemovedThreadIDs = (subreddit = '', page = 1) => { +// if (subreddit.toLowerCase() === 'all') { +// subreddit = '' +// } +// +// return window.fetch(`${baseURL}/threads?subreddit=${subreddit}&page=${page - 1}`) +// .then(response => response.json()) +// .catch(() => { throw new Error('Could not get removed threads') }) +//} diff --git a/src/index.js b/src/index.js index 9d73e32..eea9e2d 100644 --- a/src/index.js +++ b/src/index.js @@ -5,7 +5,7 @@ import { Provider } from 'unstated' import Header from './pages/common/Header' import About from './pages/about' -import Subreddit from './pages/subreddit' +//import Subreddit from './pages/subreddit' import Thread from './pages/thread' import NotFound from './pages/404' @@ -16,15 +16,13 @@ ReactDOM.render(
- + - -
diff --git a/src/pages/common/Header.js b/src/pages/common/Header.js index 833cd43..b0aa9ab 100644 --- a/src/pages/common/Header.js +++ b/src/pages/common/Header.js @@ -9,8 +9,7 @@ const Header = props => ( Unddit
diff --git a/src/pages/common/Post.js b/src/pages/common/Post.js index 4053aab..0e71fe7 100644 --- a/src/pages/common/Post.js +++ b/src/pages/common/Post.js @@ -44,7 +44,7 @@ export default (props) => {
submitted {prettyDate(props.created_utc)} by  {props.author} -  to /r/{props.subreddit} +  to /r/{props.subreddit}
{props.selftext &&
} diff --git a/src/pages/subreddit/SubredditPagination.js b/src/pages/subreddit/SubredditPagination.js index 624a45f..93ff525 100644 --- a/src/pages/subreddit/SubredditPagination.js +++ b/src/pages/subreddit/SubredditPagination.js @@ -1,25 +1,25 @@ -import React from 'react' - -export default (props) => { - let pageination = - - for (let i = props.start; i <= props.end; i++) { - if (props.currentPage === i) { - pageination += {i} - } else { - pageination += {i} - } - } - return ( - - ) -} +//import React from 'react' +// +//export default (props) => { +// let pageination = +// +// for (let i = props.start; i <= props.end; i++) { +// if (props.currentPage === i) { +// pageination += {i} +// } else { +// pageination += {i} +// } +// } +// return ( +// +// ) +//} diff --git a/src/pages/subreddit/SubredditSort.js b/src/pages/subreddit/SubredditSort.js index cf8ed50..a3da5b4 100644 --- a/src/pages/subreddit/SubredditSort.js +++ b/src/pages/subreddit/SubredditSort.js @@ -1,21 +1,21 @@ -import React from 'react' - -export default (props) => { - const isSelected = time => props.time === time - - return ( -
- top post of /r/{props.subreddit} from: - -
- ) -} +//import React from 'react' +// +//export default (props) => { +// const isSelected = time => props.time === time +// +// return ( +//
+// top post of /r/{props.subreddit} from: +// +//
+// ) +//} diff --git a/src/pages/subreddit/index.js b/src/pages/subreddit/index.js index 8604023..fa5347e 100644 --- a/src/pages/subreddit/index.js +++ b/src/pages/subreddit/index.js @@ -1,73 +1,73 @@ -import React from 'react' -import { Link } from 'react-router-dom' -import { getRemovedThreadIDs } from '../../api/removeddit' -import { getThreads } from '../../api/reddit' -import Post from '../common/Post' -import { connect } from '../../state' - -class Subreddit extends React.Component { - state = { - threads: [], - loading: true - } - - componentDidMount() { - const { subreddit = 'all' } = this.props.match.params - this.getRemovedThreads(subreddit) - } - - // Check if the subreddit has changed in the url, and fetch threads accordingly - componentDidUpdate(prevProps) { - const { subreddit: newSubreddit = 'all' } = this.props.match.params - const { subreddit = 'all' } = prevProps.match.params - - if (subreddit !== newSubreddit) { - this.getRemovedThreads(newSubreddit) - } - } - - // Download thread IDs from removeddit API, then thread info from reddit API - getRemovedThreads(subreddit) { - document.title = `/r/${subreddit}` - this.setState({ threads: [], loading: true }) - this.props.global.setLoading('Loading removed threads...') - - getRemovedThreadIDs(subreddit) - .then(threadIDs => getThreads(threadIDs)) - .then(threads => { - threads.forEach(thread => { - thread.removed = true - thread.selftext = '' - }) - this.setState({ threads, loading: false }) - this.props.global.setSuccess() - }) - .catch(this.props.global.setError) - } - - render() { - const { subreddit = 'all' } = this.props.match.params - const noThreadsFound = this.state.threads.length === 0 && !this.state.loading - - return ( - -
- /r/{subreddit} - - reddit - - reveddit -
- { - noThreadsFound - ?

No removed threads found for /r/{subreddit}

- : this.state.threads.map(thread => ( - - )) - } -
- ) - } -} - -export default connect(Subreddit) +//import React from 'react' +//import { Link } from 'react-router-dom' +//import { getRemovedThreadIDs } from '../../api/removeddit' +//import { getThreads } from '../../api/reddit' +//import Post from '../common/Post' +//import { connect } from '../../state' +// +//class Subreddit extends React.Component { +// state = { +// threads: [], +// loading: true +// } +// +// componentDidMount() { +// const { subreddit = 'all' } = this.props.match.params +// this.getRemovedThreads(subreddit) +// } +// +// // Check if the subreddit has changed in the url, and fetch threads accordingly +// componentDidUpdate(prevProps) { +// const { subreddit: newSubreddit = 'all' } = this.props.match.params +// const { subreddit = 'all' } = prevProps.match.params +// +// if (subreddit !== newSubreddit) { +// this.getRemovedThreads(newSubreddit) +// } +// } +// +// // Download thread IDs from removeddit API, then thread info from reddit API +// getRemovedThreads(subreddit) { +// document.title = `/r/${subreddit}` +// this.setState({ threads: [], loading: true }) +// this.props.global.setLoading('Loading removed threads...') +// +// getRemovedThreadIDs(subreddit) +// .then(threadIDs => getThreads(threadIDs)) +// .then(threads => { +// threads.forEach(thread => { +// thread.removed = true +// thread.selftext = '' +// }) +// this.setState({ threads, loading: false }) +// this.props.global.setSuccess() +// }) +// .catch(this.props.global.setError) +// } +// +// render() { +// const { subreddit = 'all' } = this.props.match.params +// const noThreadsFound = this.state.threads.length === 0 && !this.state.loading +// +// return ( +// +//
+// /r/{subreddit} +// +// reddit +// +// reveddit +//
+// { +// noThreadsFound +// ?

No removed threads found for /r/{subreddit}

+// : this.state.threads.map(thread => ( +// +// )) +// } +//
+// ) +// } +//} +// +//export default connect(Subreddit)