From 5e8472e29d89f379ee4c47fe26b5eaaae7264ea8 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 31 Mar 2022 20:47:28 -0500 Subject: [PATCH] EmojiSelector: fix onReact prop --- app/soapbox/components/emoji_selector.tsx | 8 +++---- app/soapbox/components/status_action_bar.js | 24 ++++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/app/soapbox/components/emoji_selector.tsx b/app/soapbox/components/emoji_selector.tsx index 8e8c94d49..15a0146c5 100644 --- a/app/soapbox/components/emoji_selector.tsx +++ b/app/soapbox/components/emoji_selector.tsx @@ -16,7 +16,7 @@ const mapStateToProps = (state: RootState) => ({ interface IEmojiSelector { allowedEmoji: ImmutableList, - onReact: (emoji: string) => (e?: MouseEvent) => void, + onReact: (emoji: string) => void, onUnfocus: () => void, visible: boolean, focused?: boolean, @@ -25,7 +25,7 @@ interface IEmojiSelector { class EmojiSelector extends ImmutablePureComponent { static defaultProps: Partial = { - onReact: () => () => {}, + onReact: () => {}, onUnfocus: () => {}, visible: false, } @@ -87,10 +87,10 @@ class EmojiSelector extends ImmutablePureComponent { } } - handleReact = (emoji: string) => () => { + handleReact = (emoji: string) => (): void => { const { onReact, focused, onUnfocus } = this.props; - onReact(emoji)(); + onReact(emoji); if (focused) { onUnfocus(); diff --git a/app/soapbox/components/status_action_bar.js b/app/soapbox/components/status_action_bar.js index 5844ac41f..367ae7b04 100644 --- a/app/soapbox/components/status_action_bar.js +++ b/app/soapbox/components/status_action_bar.js @@ -168,24 +168,28 @@ class StatusActionBar extends ImmutablePureComponent { if (features.emojiReacts && isUserTouching()) { if (this.state.emojiSelectorVisible) { - this.handleReactClick(meEmojiReact)(); + this.handleReact(meEmojiReact); } else { this.setState({ emojiSelectorVisible: true }); } } else { - this.handleReactClick(meEmojiReact)(); + this.handleReact(meEmojiReact); } } + handleReact = emoji => { + const { me, dispatch, onOpenUnauthorizedModal, status } = this.props; + if (me) { + dispatch(simpleEmojiReact(status, emoji)); + } else { + onOpenUnauthorizedModal('FAVOURITE'); + } + this.setState({ emojiSelectorVisible: false }); + } + handleReactClick = emoji => { return e => { - const { me, dispatch, onOpenUnauthorizedModal, status } = this.props; - if (me) { - dispatch(simpleEmojiReact(status, emoji)); - } else { - onOpenUnauthorizedModal('FAVOURITE'); - } - this.setState({ emojiSelectorVisible: false }); + this.handleReact(emoji); }; } @@ -667,7 +671,7 @@ class StatusActionBar extends ImmutablePureComponent { onMouseLeave={this.handleLikeButtonLeave} >