2020-05-19 20:54:05 -07:00
|
|
|
import React from 'react';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import emojify from 'gabsocial/features/emoji/emoji';
|
|
|
|
|
|
|
|
// https://emojipedia.org/facebook/
|
|
|
|
const ALLOWED_EMOJI = [
|
|
|
|
'👍',
|
|
|
|
'❤️',
|
|
|
|
'😂',
|
|
|
|
'😯',
|
|
|
|
'😢',
|
|
|
|
'😡',
|
|
|
|
];
|
|
|
|
|
|
|
|
export class StatusInteractionBar extends React.Component {
|
|
|
|
|
|
|
|
propTypes = {
|
|
|
|
status: ImmutablePropTypes.map,
|
|
|
|
}
|
|
|
|
|
|
|
|
sortEmoji = emojiReacts => (
|
2020-05-19 21:25:49 -07:00
|
|
|
emojiReacts // TODO: Sort by count
|
2020-05-19 20:54:05 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
mergeEmoji = emojiReacts => (
|
|
|
|
emojiReacts // TODO: Merge similar emoji
|
|
|
|
);
|
|
|
|
|
|
|
|
filterEmoji = emojiReacts => (
|
|
|
|
emojiReacts.filter(emojiReact => (
|
|
|
|
ALLOWED_EMOJI.includes(emojiReact.get('name'))
|
|
|
|
)))
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { status } = this.props;
|
|
|
|
const emojiReacts = status.getIn(['pleroma', 'emoji_reactions']);
|
2020-05-19 21:25:49 -07:00
|
|
|
const likeCount = status.get('favourites_count');
|
2020-05-19 20:54:05 -07:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2020-05-19 21:25:49 -07:00
|
|
|
{likeCount > 0 && <span className='emoji-react'>
|
|
|
|
<span
|
|
|
|
className='emoji-react--emoji'
|
|
|
|
dangerouslySetInnerHTML={{ __html: emojify('👍') }}
|
|
|
|
/>
|
|
|
|
<span className='emoji-react--count'>{likeCount}</span>
|
|
|
|
</span>}
|
2020-05-19 21:08:19 -07:00
|
|
|
{this.filterEmoji(emojiReacts).map(e => (
|
|
|
|
<span className='emoji-react'>
|
2020-05-19 21:25:49 -07:00
|
|
|
<span
|
|
|
|
className='emoji-react--emoji'
|
|
|
|
dangerouslySetInnerHTML={{ __html: emojify(e.get('name')) }}
|
|
|
|
/>
|
|
|
|
<span className='emoji-react--count'>{e.get('count')}</span>
|
2020-05-19 21:08:19 -07:00
|
|
|
</span>
|
|
|
|
))}
|
2020-05-19 20:54:05 -07:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|