From fafdc8ef8aecc4c8b15f18f0994533863d612264 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 11 Dec 2020 09:12:54 -0600 Subject: [PATCH 1/4] Fix heart emoji react for Pleroma develop branch --- app/soapbox/utils/emoji_reacts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/soapbox/utils/emoji_reacts.js b/app/soapbox/utils/emoji_reacts.js index 03b80a39a..ae73df165 100644 --- a/app/soapbox/utils/emoji_reacts.js +++ b/app/soapbox/utils/emoji_reacts.js @@ -7,7 +7,7 @@ import { // I've customized them. export const ALLOWED_EMOJI = [ '👍', - '❤', + '❤️', '😆', '😮', '😢', From 3d4bd238707a12c466c64e699e369774edc1118a Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 24 Dec 2020 14:40:47 -0600 Subject: [PATCH 2/4] Fix emoji heart tests --- .../__tests__/__snapshots__/emoji_selector-test.js.snap | 2 +- app/soapbox/utils/__tests__/emoji_reacts-test.js | 2 +- app/soapbox/utils/emoji_reacts.js | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/soapbox/components/__tests__/__snapshots__/emoji_selector-test.js.snap b/app/soapbox/components/__tests__/__snapshots__/emoji_selector-test.js.snap index 6b6307012..80bd49f8e 100644 --- a/app/soapbox/components/__tests__/__snapshots__/emoji_selector-test.js.snap +++ b/app/soapbox/components/__tests__/__snapshots__/emoji_selector-test.js.snap @@ -16,7 +16,7 @@ exports[` renders correctly 1`] = ` className="emoji-react-selector__emoji" dangerouslySetInnerHTML={ Object { - "__html": "\\"❤\\"", + "__html": "\\"❤️\\"", } } /> diff --git a/app/soapbox/utils/__tests__/emoji_reacts-test.js b/app/soapbox/utils/__tests__/emoji_reacts-test.js index 4663304b2..e21dda5e1 100644 --- a/app/soapbox/utils/__tests__/emoji_reacts-test.js +++ b/app/soapbox/utils/__tests__/emoji_reacts-test.js @@ -158,7 +158,7 @@ describe('getReactForStatus', () => { ], }, }); - expect(getReactForStatus(status)).toEqual('❤'); + expect(getReactForStatus(status, ALLOWED_EMOJI)).toEqual('❤'); }); it('returns a thumbs-up for a favourite', () => { diff --git a/app/soapbox/utils/emoji_reacts.js b/app/soapbox/utils/emoji_reacts.js index ae73df165..774fdba39 100644 --- a/app/soapbox/utils/emoji_reacts.js +++ b/app/soapbox/utils/emoji_reacts.js @@ -75,11 +75,12 @@ export const reduceEmoji = (emojiReacts, favouritesCount, favourited, allowedEmo emojiReacts, favouritesCount, favourited, ))), allowedEmoji)); -export const getReactForStatus = status => { +export const getReactForStatus = (status, allowedEmoji=ALLOWED_EMOJI) => { return reduceEmoji( status.getIn(['pleroma', 'emoji_reactions'], ImmutableList()), - status.get('favourites_count'), + status.get('favourites_count', 0), status.get('favourited'), + allowedEmoji, ).filter(e => e.get('me') === true) .getIn([0, 'name']); }; From e4344c956101129d80651de6f791a84c612d730c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 24 Dec 2020 18:17:53 -0600 Subject: [PATCH 3/4] Let allowedEmoji be customizable by the admin, fixes #538 --- app/soapbox/actions/soapbox.js | 10 +++++++++- app/soapbox/components/emoji_selector.js | 15 +++++++++++---- app/soapbox/components/status.js | 1 + app/soapbox/components/status_action_bar.js | 8 +++++--- app/soapbox/containers/status_container.js | 2 ++ .../features/status/components/action_bar.js | 7 ++++--- .../features/status/components/detailed_status.js | 2 +- .../status/components/status_interaction_bar.js | 12 +++++++++++- app/soapbox/features/status/index.js | 3 +++ 9 files changed, 47 insertions(+), 13 deletions(-) diff --git a/app/soapbox/actions/soapbox.js b/app/soapbox/actions/soapbox.js index 58a2417c7..ee203dbb1 100644 --- a/app/soapbox/actions/soapbox.js +++ b/app/soapbox/actions/soapbox.js @@ -18,10 +18,18 @@ export const defaultConfig = ImmutableMap({ navlinks: ImmutableMap({ homeFooter: ImmutableList(), }), + allowedEmoji: ImmutableList([ + '👍', + '❤️', + '😆', + '😮', + '😢', + '😩', + ]), }); export function getSoapboxConfig(state) { - return defaultConfig.mergeDeep(state.get('soapbox')); + return defaultConfig.merge(state.get('soapbox')); } export function fetchSoapboxConfig() { diff --git a/app/soapbox/components/emoji_selector.js b/app/soapbox/components/emoji_selector.js index 7ef0e2b0a..4cd0395e3 100644 --- a/app/soapbox/components/emoji_selector.js +++ b/app/soapbox/components/emoji_selector.js @@ -1,10 +1,17 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { ALLOWED_EMOJI } from 'soapbox/utils/emoji_reacts'; +import ImmutablePureComponent from 'react-immutable-pure-component'; +import { connect } from 'react-redux'; import emojify from 'soapbox/features/emoji/emoji'; +import { getSoapboxConfig } from 'soapbox/actions/soapbox'; import classNames from 'classnames'; -export default class EmojiSelector extends React.Component { +const mapStateToProps = state => ({ + allowedEmoji: getSoapboxConfig(state).get('allowedEmoji'), +}); + +export default @connect(mapStateToProps) +class EmojiSelector extends ImmutablePureComponent { static propTypes = { onReact: PropTypes.func.isRequired, @@ -17,11 +24,11 @@ export default class EmojiSelector extends React.Component { } render() { - const { onReact, visible } = this.props; + const { onReact, visible, allowedEmoji } = this.props; return (
- {ALLOWED_EMOJI.map((emoji, i) => ( + {allowedEmoji.map((emoji, i) => (
From 83d7622e172cce3130182ab5ed0638914824a6c4 Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 24 Dec 2020 22:48:22 -0700 Subject: [PATCH 4/4] Fix emoji selector test failing --- app/soapbox/components/__tests__/emoji_selector-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/soapbox/components/__tests__/emoji_selector-test.js b/app/soapbox/components/__tests__/emoji_selector-test.js index c475aae4b..c8083c3aa 100644 --- a/app/soapbox/components/__tests__/emoji_selector-test.js +++ b/app/soapbox/components/__tests__/emoji_selector-test.js @@ -1,10 +1,10 @@ import React from 'react'; -import renderer from 'react-test-renderer'; +import { createComponent } from 'soapbox/test_helpers'; import EmojiSelector from '../emoji_selector'; describe('', () => { it('renders correctly', () => { - const component = renderer.create(); + const component = createComponent(); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); });