diff options
Diffstat (limited to 'vnext/src/components/Feeds.js')
-rw-r--r-- | vnext/src/components/Feeds.js | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/vnext/src/components/Feeds.js b/vnext/src/components/Feeds.js index b8367de4..0216a1b4 100644 --- a/vnext/src/components/Feeds.js +++ b/vnext/src/components/Feeds.js @@ -1,21 +1,22 @@ import React from 'react'; import PropTypes from 'prop-types'; +import { Link } from 'react-router-dom'; import * as qs from 'query-string'; import Message from './Message'; import Spinner from './Spinner'; export function Discover(props) { - return (<Feed query={{ baseUrl: "https://api.juick.com/messages"}} {...props} />) + return (<Feed query={{ baseUrl: "https://api.juick.com/messages" }} {...props} />) } export function Discussions(props) { - return (<Feed authRequired="true" query={{ baseUrl: "https://api.juick.com/messages/discussions"}} {...props} />) + return (<Feed authRequired="true" query={{ baseUrl: "https://api.juick.com/messages/discussions" }} {...props} />) } export function Blog(props) { const { user } = props.match.params; - return (<Feed query={{ baseUrl: `https://api.juick.com/messages`, search: { uname: user }}} {...props} />) + return (<Feed query={{ baseUrl: `https://api.juick.com/messages`, search: { uname: user } }} {...props} />) } export function Tag(props) { @@ -34,7 +35,7 @@ class Feed extends React.Component { componentDidMount() { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; - this.loadMessages(this.props.visitor.hash); + this.loadMessages(this.props.visitor.hash, this.props.location.search); } componentWillReceiveProps(nextProps) { if (this.props.location.search != nextProps.location.search @@ -67,9 +68,23 @@ class Feed extends React.Component { } render() { - var nodes = this.state.msgs.map(msg => { - return (<Message key={msg.mid} data={msg} visitor={this.props.visitor} />); - }); + const { tag } = qs.parse(this.props.location.search || {}); + const nodes = ( + <React.Fragment> + { + tag && ( + <p className="page"> + <Link to={{ pathname: `/tag/${tag}` }}> + <span>← All posts with tag </span><b>{tag}</b> + </Link> + </p> + ) + } + {this.state.msgs.map(msg => + <Message key={msg.mid} data={msg} visitor={this.props.visitor} />) + } + </React.Fragment> + ); return this.state.msgs.length > 0 ? ( <div className="msgs" id="content">{nodes}</div> ) : <div className="msgs" id="content"><Spinner /><Spinner /><Spinner /><Spinner /></div>; |