diff options
author | Vitaly Takmazov | 2018-06-16 18:19:54 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:52 +0300 |
commit | c754cbba643d7ea1e6312c685f4b321ab5efba6b (patch) | |
tree | 610930ebd1b407b9f143f988c1ae00ae73c1d9f6 /vnext/src/components/Discover.js | |
parent | b96369be938bd767c35d3e0a888eeda3c9c79d10 (diff) |
Navigation fix
Diffstat (limited to 'vnext/src/components/Discover.js')
-rw-r--r-- | vnext/src/components/Discover.js | 22 |
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 }; |