Commit c6c73f3e authored by Quoc Huy Nguyen Dinh's avatar Quoc Huy Nguyen Dinh
Browse files

Merge branch 'develop' into '144-fix-storybook'

# Conflicts:
#   src/app/components/pages/PostsIndexLayout.jsx
parents 4a55d1b8 c662e4d5
......@@ -242,7 +242,10 @@ module.exports = {
const order = account_name ? route.category : route.order || 'trending';
const hive = ifHive(category);
const community = state.global.getIn(['community', hive], null);
let community = state.global.getIn(['community', hive], null);
if (typeof community === 'string') {
community = null;
}
const enableAds = ownProps.gptEnabled && !GptUtils.HasBannedTags([category], state.app.getIn(['googleAds', 'gptBannedTags']));
......
......@@ -13,13 +13,19 @@ import CommunityPane from 'app/components/elements/CommunityPane';
import CommunityPaneMobile from 'app/components/elements/CommunityPaneMobile';
import Topics from './Topics';
class PostsIndexLayout extends React.Component {
static propTypes = {
username: PropTypes.string,
blogmode: PropTypes.bool,
topics: PropTypes.object,
};
const propTypes = {
username: PropTypes.string,
blogmode: PropTypes.bool,
topics: PropTypes.object,
};
const defaultProps = {
username: '',
blogmode: true,
topics: {},
};
class PostsIndexLayout extends React.Component {
componentWillMount() {
const { subscriptions, getSubscriptions, username } = this.props;
if (!subscriptions && username) getSubscriptions(username);
......@@ -27,13 +33,13 @@ class PostsIndexLayout extends React.Component {
componentDidUpdate(prevProps) {
const { subscriptions, getSubscriptions, username } = this.props;
if (!subscriptions && username && username != prevProps.username) getSubscriptions(username);
if (!subscriptions && username && username !== prevProps.username) getSubscriptions(username);
}
render() {
const {
topics, subscriptions, enableAds, community, username, blogmode, isBrowser, children
} = this.props;
topics, subscriptions, enableAds, community, username, blogmode, isBrowser, children
} = this.props;
return (
<div className={'PostsIndex row ' + (blogmode ? 'layout-block' : 'layout-list')}>
......@@ -77,13 +83,21 @@ class PostsIndexLayout extends React.Component {
}
}
PostsIndexLayout.propTypes = propTypes;
PostsIndexLayout.defaultProps = defaultProps;
export default connect(
(state, props) => {
const username = state.user.getIn(['current', 'username']) || state.offchain.get('account');
let community = state.global.getIn(['community', props.category], null);
if (typeof community === 'string') {
community = null;
}
return {
blogmode: props.blogmode,
enableAds: props.enableAds,
community: state.global.getIn(['community', props.category], null),
community,
subscriptions: state.global.getIn(['subscriptions', username], null),
topics: state.global.getIn(['topics'], List()),
isBrowser: process.env.BROWSER,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment