aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-06-18 22:13:11 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:52 +0300
commit06403d9710daaebd642ad78c4ffce4a558a747ff (patch)
tree2496d5594ffcd475610d5288cf4555e821795f7e
parent8046731d2e2274fc7de7936584b76c5ed19a2a59 (diff)
user blog feed
-rw-r--r--vnext/src/components/Feeds.js18
-rw-r--r--vnext/src/index.js3
2 files changed, 15 insertions, 6 deletions
diff --git a/vnext/src/components/Feeds.js b/vnext/src/components/Feeds.js
index b70720ac..cf593b5e 100644
--- a/vnext/src/components/Feeds.js
+++ b/vnext/src/components/Feeds.js
@@ -6,11 +6,16 @@ import Message from './Message';
import Spinner from './Spinner';
export function Discover(props) {
- return (<Feed 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" 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} />)
}
class Feed extends React.Component {
@@ -34,8 +39,8 @@ class Feed extends React.Component {
}
loadMessages(hash = '', filter = '') {
this.setState({ msgs: [] })
- let params = qs.parse(filter) || {}
- let url = this.props.baseUrl;
+ let params = Object.assign({}, qs.parse(filter) || {}, this.props.query.search || {});
+ let url = this.props.query.baseUrl;
if (hash) {
params.hash = hash;
}
@@ -68,5 +73,8 @@ class Feed extends React.Component {
Feed.propTypes = {
msgs: PropTypes.array,
- baseUrl: PropTypes.string
+ query: PropTypes.shape({
+ baseUrl: PropTypes.string.isRequired,
+ search: PropTypes.array
+ })
};
diff --git a/vnext/src/index.js b/vnext/src/index.js
index e5eda859..4142f2c4 100644
--- a/vnext/src/index.js
+++ b/vnext/src/index.js
@@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
import Icon from './components/Icon';
-import { Discover, Discussions } from './components/Feeds';
+import { Discover, Discussions, Blog } from './components/Feeds';
import Post from './components/Post';
import Thread from './components/Thread';
import LoginButton from './components/LoginButton';
@@ -120,6 +120,7 @@ class App extends React.Component {
<section id="content">
<Route exact path="/" render={(props) => <Discover visitor={this.state.visitor} {...props} />} />
<Route exact path="/discussions" render={(props) => <Discussions visitor={this.state.visitor} {...props} />} />
+ <Route exact path="/:user" render={(props) => <Blog visitor={this.state.visitor} {...props} />} />
<Route exact path="/:user/:mid" render={(props) => <Thread visitor={this.state.visitor} {...props} />} />
<Route exact path="/post" render={(props) => <Post visitor={this.state.visitor} {...props} />} />
</section>