aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/Discover.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-06-16 18:19:54 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:52 +0300
commitc754cbba643d7ea1e6312c685f4b321ab5efba6b (patch)
tree610930ebd1b407b9f143f988c1ae00ae73c1d9f6 /vnext/src/components/Discover.js
parentb96369be938bd767c35d3e0a888eeda3c9c79d10 (diff)
Navigation fix
Diffstat (limited to 'vnext/src/components/Discover.js')
-rw-r--r--vnext/src/components/Discover.js22
1 files changed, 18 insertions, 4 deletions
diff --git a/vnext/src/components/Discover.js b/vnext/src/components/Discover.js
index 63a0cad0..daf2902f 100644
--- a/vnext/src/components/Discover.js
+++ b/vnext/src/components/Discover.js
@@ -1,9 +1,9 @@
import 'whatwg-fetch';
import React from 'react';
import PropTypes from 'prop-types';
-import queryString from 'query-string';
import Message from './Message';
+import Icon from './Icon';
export default class Discover extends React.Component {
constructor(props) {
@@ -18,8 +18,14 @@ export default class Discover extends React.Component {
componentDidMount() {
this.loadMessages();
}
- loadMessages() {
- const url = 'https://api.juick.com/messages' + this.state.search;
+ componentWillReceiveProps(nextProps) {
+ if (this.props.location.search != nextProps.location.search) {
+ this.loadMessages(nextProps.location.search)
+ }
+ }
+ loadMessages(filter = '') {
+ this.setState({ msgs: []})
+ const url = 'https://api.juick.com/messages' + filter;
fetch(url)
.then(response => {
return response.json()
@@ -35,12 +41,20 @@ export default class Discover extends React.Component {
var nodes = this.state.msgs.map(msg => {
return (<Message key={msg.mid} data={msg}/>);
});
- return (
+ return this.state.msgs.length > 0 ? (
<div className="msgs" id="content">{nodes}</div>
+ ) : (
+ <div id="content" style={centeredStyle}><Icon name="ei-spinner" size="m"/></div>
);
}
}
+const centeredStyle = {
+ display: 'flex',
+ justifyContent: 'center',
+ alignItems: 'center'
+}
+
Discover.propTypes = {
msgs: PropTypes.array
};