mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-30 19:09:03 +01:00
limit number of reactions displayed
Too many reactions on a single post quickly get spammy, so they are now sorted by count and only the first MAX_REACTIONS number of different emojis are actually displayed.
This commit is contained in:
parent
21b5bb587d
commit
38b8c494b8
1 changed files with 5 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import { reduceMotion } from '../initial_state';
|
import { maxReactions, reduceMotion } from '../initial_state';
|
||||||
import spring from 'react-motion/lib/spring';
|
import spring from 'react-motion/lib/spring';
|
||||||
import TransitionMotion from 'react-motion/lib/TransitionMotion';
|
import TransitionMotion from 'react-motion/lib/TransitionMotion';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
@ -36,7 +36,10 @@ export default class StatusReactions extends ImmutablePureComponent {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { reactions } = this.props;
|
const { reactions } = this.props;
|
||||||
const visibleReactions = reactions.filter(x => x.get('count') > 0);
|
const visibleReactions = reactions
|
||||||
|
.filter(x => x.get('count') > 0)
|
||||||
|
.sort((a, b) => b.get('count') - a.get('count'))
|
||||||
|
.filter((_, i) => i < maxReactions);
|
||||||
|
|
||||||
const styles = visibleReactions.map(reaction => ({
|
const styles = visibleReactions.map(reaction => ({
|
||||||
key: reaction.get('name'),
|
key: reaction.get('name'),
|
||||||
|
|
Loading…
Reference in a new issue