navigation.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { connect } from 'react-redux';
  4. import FeaturedTags from 'mastodon/features/account/containers/featured_tags_container';
  5. import { normalizeForLookup } from 'mastodon/reducers/accounts_map';
  6. const mapStateToProps = (state, { match: { params: { acct } } }) => {
  7. const accountId = state.getIn(['accounts_map', normalizeForLookup(acct)]);
  8. if (!accountId) {
  9. return {
  10. isLoading: true,
  11. };
  12. }
  13. return {
  14. accountId,
  15. isLoading: false,
  16. };
  17. };
  18. export default @connect(mapStateToProps)
  19. class AccountNavigation extends React.PureComponent {
  20. static propTypes = {
  21. match: PropTypes.shape({
  22. params: PropTypes.shape({
  23. acct: PropTypes.string,
  24. tagged: PropTypes.string,
  25. }).isRequired,
  26. }).isRequired,
  27. accountId: PropTypes.string,
  28. isLoading: PropTypes.bool,
  29. };
  30. render () {
  31. const { accountId, isLoading, match: { params: { tagged } } } = this.props;
  32. if (isLoading) {
  33. return null;
  34. }
  35. return (
  36. <>
  37. <div className='flex-spacer' />
  38. <FeaturedTags accountId={accountId} tagged={tagged} />
  39. </>
  40. );
  41. }
  42. }