import PropTypes from 'prop-types'; import React from 'react'; import { FormattedMessage, injectIntl, defineMessages } from 'react-intl'; import { Helmet } from 'react-helmet'; import { Link, withRouter } from 'react-router-dom'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { connect } from 'react-redux'; import { debounce } from 'lodash'; import { fetchAccount } from 'flavours/glitch/actions/accounts'; import { focusCompose } from 'flavours/glitch/actions/compose'; import { closeOnboarding } from 'flavours/glitch/actions/onboarding'; import Column from 'flavours/glitch/features/ui/components/column'; import { me } from 'flavours/glitch/initial_state'; import { makeGetAccount } from 'flavours/glitch/selectors'; import { assetHost } from 'flavours/glitch/utils/config'; import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router'; import illustration from 'mastodon/../images/elephant_ui_conversation.svg'; import ArrowSmallRight from './components/arrow_small_right'; import Step from './components/step'; import Follows from './follows'; import Share from './share'; 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 propTypes = { dispatch: PropTypes.func.isRequired, account: ImmutablePropTypes.record, multiColumn: PropTypes.bool, ...WithRouterPropTypes, }; state = { step: null, profileClicked: false, shareClicked: false, }; handleClose = () => { const { dispatch, history } = this.props; dispatch(closeOnboarding()); history.push('/home'); }; handleProfileClick = () => { this.setState({ profileClicked: true }); }; handleFollowClick = () => { this.setState({ step: 'follows' }); }; handleComposeClick = () => { const { dispatch, intl, history } = this.props; dispatch(focusCompose(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 withRouter(connect(mapStateToProps)(injectIntl(Onboarding)));