]> cat aescling's git repositories - mastodon.git/blob - app/javascript/mastodon/features/getting_started/components/trends.js
Add header to trends section and change refresh rate to 15 minutes (#11641)
[mastodon.git] / app / javascript / mastodon / features / getting_started / components / trends.js
1 import React from 'react';
2 import ImmutablePureComponent from 'react-immutable-pure-component';
3 import PropTypes from 'prop-types';
4 import ImmutablePropTypes from 'react-immutable-proptypes';
5 import Hashtag from 'mastodon/components/hashtag';
6 import { FormattedMessage } from 'react-intl';
7
8 export default class Trends extends ImmutablePureComponent {
9
10 static defaultProps = {
11 loading: false,
12 };
13
14 static propTypes = {
15 trends: ImmutablePropTypes.list,
16 fetchTrends: PropTypes.func.isRequired,
17 };
18
19 componentDidMount () {
20 this.props.fetchTrends();
21 this.refreshInterval = setInterval(() => this.props.fetchTrends(), 900 * 1000);
22 }
23
24 componentWillUnmount () {
25 if (this.refreshInterval) {
26 clearInterval(this.refreshInterval);
27 }
28 }
29
30 render () {
31 const { trends } = this.props;
32
33 if (!trends || trends.isEmpty()) {
34 return null;
35 }
36
37 return (
38 <div className='getting-started__trends'>
39 <h4><FormattedMessage id='trends.trending_now' defaultMessage='Trending now' /></h4>
40
41 {trends.take(3).map(hashtag => <Hashtag key={hashtag.get('name')} hashtag={hashtag} />)}
42 </div>
43 );
44 }
45
46 }
This page took 0.077684 seconds and 4 git commands to generate.