import React from 'react'; import PropTypes from 'prop-types'; import ImmutablePureComponent from 'react-immutable-pure-component'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { connect } from 'react-redux'; import { focusCompose } from 'mastodon/actions/compose'; import Column from 'mastodon/features/ui/components/column'; import { Helmet } from 'react-helmet'; import illustration from 'mastodon/../images/elephant_ui_conversation.svg'; import { Link } from 'react-router-dom'; import { me } from 'mastodon/initial_state'; import { makeGetAccount } from 'mastodon/selectors'; import { closeOnboarding } from 'mastodon/actions/onboarding'; import { fetchAccount } from 'mastodon/actions/accounts'; import Follows from './follows'; import Share from './share'; import Step from './components/step'; import ArrowSmallRight from './components/arrow_small_right'; import { FormattedMessage, injectIntl, defineMessages } from 'react-intl'; import { debounce } from 'lodash'; const messages = defineMessages({ template: { id: 'onboarding.compose.template', defaultMessage: 'Hello #Mastodon!' }, }); const mapStateToProps = () => { const getAccount = makeGetAccount(); return state => ({ account: getAccount(state, me), }); }; class Onboarding extends ImmutablePureComponent { static contextTypes = { router: PropTypes.object.isRequired, }; static propTypes = { dispatch: PropTypes.func.isRequired, account: ImmutablePropTypes.map, multiColumn: PropTypes.bool, }; state = { step: null, profileClicked: false, shareClicked: false, }; handleClose = () => { const { dispatch } = this.props; const { router } = this.context; dispatch(closeOnboarding()); router.history.push('/home'); }; handleProfileClick = () => { this.setState({ profileClicked: true }); }; handleFollowClick = () => { this.setState({ step: 'follows' }); }; handleComposeClick = () => { const { dispatch, intl } = this.props; const { router } = this.context; dispatch(focusCompose(router.history, intl.formatMessage(messages.template))); }; handleShareClick = () => { this.setState({ step: 'share', shareClicked: true }); }; handleBackClick = () => { this.setState({ step: null }); }; handleWindowFocus = debounce(() => { const { dispatch, account } = this.props; dispatch(fetchAccount(account.get('id'))); }, 1000, { trailing: true }); componentDidMount () { window.addEventListener('focus', this.handleWindowFocus, false); } componentWillUnmount () { window.removeEventListener('focus', this.handleWindowFocus); } render () { const { account, multiColumn } = this.props; const { step, shareClicked } = this.state; switch(step) { case 'follows': return ; case 'share': return ; } return ( 0 && account.get('note').length > 0)} icon='address-book-o' label={} description={} /> = 7} icon='user-plus' label={} description={} /> = 1} icon='pencil-square-o' label={} description={} /> } description={} /> ); } } export default connect(mapStateToProps)(injectIntl(Onboarding));