diff options
author | Vitaly Takmazov | 2018-06-16 22:13:40 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:52 +0300 |
commit | 67afd8e9378c65bff11a2aac21d95577fa916dc5 (patch) | |
tree | 299ae99f74df6285687d978c74875fc583af98e3 /vnext/src/components/Discover.js | |
parent | 9177719daf40ca63b73f78602283902b3c615bae (diff) |
Discussions
Diffstat (limited to 'vnext/src/components/Discover.js')
-rw-r--r-- | vnext/src/components/Discover.js | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/vnext/src/components/Discover.js b/vnext/src/components/Discover.js deleted file mode 100644 index a0e51160..00000000 --- a/vnext/src/components/Discover.js +++ /dev/null @@ -1,59 +0,0 @@ -import 'whatwg-fetch'; -import React from 'react'; -import PropTypes from 'prop-types'; -import * as qs from 'query-string'; - -import Message from './Message'; -import Spinner from './Spinner'; - -export default class Discover extends React.Component { - constructor(props) { - super(props); - this.state = { - msgs: [] - }; - this.loadMessages = this.loadMessages.bind(this); - } - componentDidMount() { - this.loadMessages(); - } - componentWillReceiveProps(nextProps) { - if (this.props.location.search != nextProps.location.search - || this.props.visitor != nextProps.visitor) { - this.loadMessages(nextProps.location.search) - } - } - loadMessages(filter = '') { - this.setState({ msgs: [] }) - let params = qs.parse(filter) || {} - let url = 'https://api.juick.com/messages'; - if (this.props.visitor && this.props.visitor.hash) { - params.hash = this.props.visitor.hash; - } - if (Object.keys(params).length > 0) { - url = `${url}?${qs.stringify(params)}`; - } - fetch(url) - .then(response => { - return response.json() - }) - .then(data => - this.setState({ msgs: data }) - ).catch(ex => { - console.log(ex); - }); - } - - render() { - var nodes = this.state.msgs.map(msg => { - return (<Message key={msg.mid} data={msg} />); - }); - return this.state.msgs.length > 0 ? ( - <div className="msgs" id="content">{nodes}</div> - ) : <Spinner />; - } -} - -Discover.propTypes = { - msgs: PropTypes.array -}; |