From 00be9eb3fe57348463eddad76efe27c7d0d5bf86 Mon Sep 17 00:00:00 2001 From: cwm Date: Mon, 22 Jan 2018 19:05:13 -0600 Subject: merge tootsuite pr #6313 into glitch --- .../glitch/features/getting_started/index.js | 59 +++++++++++++++++----- 1 file changed, 45 insertions(+), 14 deletions(-) (limited to 'app/javascript/flavours/glitch/features/getting_started/index.js') diff --git a/app/javascript/flavours/glitch/features/getting_started/index.js b/app/javascript/flavours/glitch/features/getting_started/index.js index 0077f193b..1ae596e4a 100644 --- a/app/javascript/flavours/glitch/features/getting_started/index.js +++ b/app/javascript/flavours/glitch/features/getting_started/index.js @@ -9,6 +9,8 @@ import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { me } from 'flavours/glitch/util/initial_state'; +import { fetchFollowRequests } from 'flavours/glitch/actions/accounts'; +import { List as ImmutableList } from 'immutable'; import { createSelector } from 'reselect'; import { fetchLists } from 'flavours/glitch/actions/lists'; @@ -45,13 +47,38 @@ const makeMapStateToProps = () => { lists: getOrderedLists(state), myAccount: state.getIn(['accounts', me]), columns: state.getIn(['settings', 'columns']), + unreadFollowRequests: state.getIn(['user_lists', 'follow_requests', 'items'], ImmutableList()).size, + unreadNotifications: state.getIn(['notifications', 'unread']), }); return mapStateToProps; }; +const mapDispatchToProps = dispatch => ({ + fetchFollowRequests: () => dispatch(fetchFollowRequests()), + + fetchLists: () => dispatch(fetchLists()), + + openSettings: () => dispatch(openModal('SETTINGS', {})), + + openOnboardingModal: (e) => { + e.preventDefault(); + this.props.dispatch(openModal('ONBOARDING')); + }, +}); + +const badgeDisplay = (number, limit) => { + if (number === 0) { + return undefined; + } else if (limit && number >= limit) { + return `${limit}+`; + } else { + return number; + } +}; + +@connect(makeMapStateToProps, mapDispatchToProps) @injectIntl -@connect(makeMapStateToProps) export default class GettingStarted extends ImmutablePureComponent { static propTypes = { @@ -59,25 +86,29 @@ export default class GettingStarted extends ImmutablePureComponent { myAccount: ImmutablePropTypes.map.isRequired, columns: ImmutablePropTypes.list, multiColumn: PropTypes.bool, - dispatch: PropTypes.func.isRequired, + fetchFollowRequests: PropTypes.func.isRequired, + unreadFollowRequests: PropTypes.number, + unreadNotifications: PropTypes.number, lists: ImmutablePropTypes.list, + fetchLists: PropTypes.func.isRequired, + openSettings: PropTypes.func.isRequired, + openOnboardingModal: PropTypes.func.isRequired, }; - openSettings = () => { - this.props.dispatch(openModal('SETTINGS', {})); + componentWillMount () { + fetchLists(); } - openOnboardingModal = (e) => { - e.preventDefault(); - this.props.dispatch(openModal('ONBOARDING')); - } + componentDidMount () { + const { myAccount, fetchFollowRequests } = this.props; - componentWillMount () { - this.props.dispatch(fetchLists()); + if (myAccount.get('locked')) { + fetchFollowRequests(); + } } render () { - const { intl, myAccount, columns, multiColumn, lists } = this.props; + const { intl, myAccount, columns, multiColumn, unreadFollowRequests, unreadNotifications, lists, openSettings } = this.props; const navItems = []; let listItems = []; @@ -88,7 +119,7 @@ export default class GettingStarted extends ImmutablePureComponent { } if (!columns.find(item => item.get('id') === 'NOTIFICATIONS')) { - navItems.push(); + navItems.push(); } if (!columns.find(item => item.get('id') === 'COMMUNITY')) { @@ -105,7 +136,7 @@ export default class GettingStarted extends ImmutablePureComponent { } if (myAccount.get('locked')) { - navItems.push(); + navItems.push(); } navItems.push(); @@ -129,7 +160,7 @@ export default class GettingStarted extends ImmutablePureComponent { {listItems} - + -- cgit From 939075899e7197e0e60c9db2f4ac0679593f278e Mon Sep 17 00:00:00 2001 From: cwm Date: Mon, 22 Jan 2018 19:38:34 -0600 Subject: remove unused openOnboardingModal from getting_started --- .../flavours/glitch/features/getting_started/index.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'app/javascript/flavours/glitch/features/getting_started/index.js') diff --git a/app/javascript/flavours/glitch/features/getting_started/index.js b/app/javascript/flavours/glitch/features/getting_started/index.js index 1ae596e4a..874f11bc8 100644 --- a/app/javascript/flavours/glitch/features/getting_started/index.js +++ b/app/javascript/flavours/glitch/features/getting_started/index.js @@ -56,15 +56,8 @@ const makeMapStateToProps = () => { const mapDispatchToProps = dispatch => ({ fetchFollowRequests: () => dispatch(fetchFollowRequests()), - fetchLists: () => dispatch(fetchLists()), - openSettings: () => dispatch(openModal('SETTINGS', {})), - - openOnboardingModal: (e) => { - e.preventDefault(); - this.props.dispatch(openModal('ONBOARDING')); - }, }); const badgeDisplay = (number, limit) => { @@ -92,7 +85,6 @@ export default class GettingStarted extends ImmutablePureComponent { lists: ImmutablePropTypes.list, fetchLists: PropTypes.func.isRequired, openSettings: PropTypes.func.isRequired, - openOnboardingModal: PropTypes.func.isRequired, }; componentWillMount () { @@ -136,7 +128,7 @@ export default class GettingStarted extends ImmutablePureComponent { } if (myAccount.get('locked')) { - navItems.push(); + navItems.push(); } navItems.push(); -- cgit From 0ddeed9377d69de8398973c253cc1a7c9f8d5a80 Mon Sep 17 00:00:00 2001 From: cwm Date: Tue, 23 Jan 2018 01:23:56 -0600 Subject: add 'this.props' to fetchLists --- app/javascript/flavours/glitch/features/getting_started/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/javascript/flavours/glitch/features/getting_started/index.js') diff --git a/app/javascript/flavours/glitch/features/getting_started/index.js b/app/javascript/flavours/glitch/features/getting_started/index.js index 874f11bc8..bf9fe118a 100644 --- a/app/javascript/flavours/glitch/features/getting_started/index.js +++ b/app/javascript/flavours/glitch/features/getting_started/index.js @@ -88,7 +88,7 @@ export default class GettingStarted extends ImmutablePureComponent { }; componentWillMount () { - fetchLists(); + this.props.fetchLists(); } componentDidMount () { -- cgit