import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { connect } from 'react-redux'; import { FormattedNumber } from 'react-intl'; import emojify from 'soapbox/features/emoji/emoji'; import { reduceEmoji } from 'soapbox/utils/emoji_reacts'; import SoapboxPropTypes from 'soapbox/utils/soapbox_prop_types'; import { Link } from 'react-router-dom'; import Icon from 'soapbox/components/icon'; import { getSoapboxConfig } from 'soapbox/actions/soapbox'; const mapStateToProps = state => ({ allowedEmoji: getSoapboxConfig(state).get('allowedEmoji'), }); export default @connect(mapStateToProps) class StatusInteractionBar extends ImmutablePureComponent { static propTypes = { status: ImmutablePropTypes.map, me: SoapboxPropTypes.me, allowedEmoji: ImmutablePropTypes.list, } getNormalizedReacts = () => { const { status } = this.props; return reduceEmoji( status.getIn(['pleroma', 'emoji_reactions']), status.get('favourites_count'), status.get('favourited'), this.props.allowedEmoji, ).reverse(); } getRepost = () => { const { status } = this.props; if (status.get('reblogs_count')) { return ( ); } return ''; } render() { const emojiReacts = this.getNormalizedReacts(); const count = emojiReacts.reduce((acc, cur) => ( acc + cur.get('count') ), 0); const repost = this.getRepost(); const EmojiReactsContainer = () => (
{emojiReacts.map((e, i) => ( {e.get('count')} ))}
{count}
); return (
{count > 0 && } {repost}
); } }