aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/Feeds.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/components/Feeds.js')
-rw-r--r--vnext/src/components/Feeds.js15
1 files changed, 6 insertions, 9 deletions
diff --git a/vnext/src/components/Feeds.js b/vnext/src/components/Feeds.js
index 5e9c14d0..0a27ed3d 100644
--- a/vnext/src/components/Feeds.js
+++ b/vnext/src/components/Feeds.js
@@ -7,6 +7,8 @@ import moment from 'moment';
import Message from './Message';
import Spinner from './Spinner';
+import { getMessages } from '../api';
+
export function Discover(props) {
const query = {
baseUrl: "https://api.juick.com/messages",
@@ -38,7 +40,7 @@ export function Blog(props) {
export function Tag(props) {
const { tag } = props.match.params;
const query = {
- baseUrl: `https://api.juick.com/messages`,
+ baseUrl: '/messages',
search: {
tag: tag
},
@@ -49,7 +51,7 @@ export function Tag(props) {
export function Home(props) {
const query = {
- baseUrl: `https://api.juick.com/home`,
+ baseUrl: '/home',
pageParam: 'before_mid'
};
return (<Feed authRequired="true" query={query} {...props} />)
@@ -81,17 +83,12 @@ class Feed extends React.Component {
if (hash) {
params.hash = hash;
}
- if (Object.keys(params).length > 0) {
- url = `${url}?${qs.stringify(params)}`;
- }
if (!params.hash && this.props.authRequired) {
this.props.history.push('/')
}
- fetch(url)
+ getMessages(url, params)
.then(response => {
- return response.json()
- })
- .then(data => {
+ const { data } = response;
const { pageParam } = this.props.query;
const lastMessage = data.slice(-1)[0] || {};
const pageValue = pageParam === 'before_mid' ? lastMessage.mid : moment.utc(lastMessage.updated).valueOf();