EmojiSelector: fix onReact prop

This commit is contained in:
Alex Gleason 2022-03-31 20:47:28 -05:00
parent 52982706fe
commit 5e8472e29d
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 18 additions and 14 deletions

View file

@ -16,7 +16,7 @@ const mapStateToProps = (state: RootState) => ({
interface IEmojiSelector { interface IEmojiSelector {
allowedEmoji: ImmutableList<string>, allowedEmoji: ImmutableList<string>,
onReact: (emoji: string) => (e?: MouseEvent) => void, onReact: (emoji: string) => void,
onUnfocus: () => void, onUnfocus: () => void,
visible: boolean, visible: boolean,
focused?: boolean, focused?: boolean,
@ -25,7 +25,7 @@ interface IEmojiSelector {
class EmojiSelector extends ImmutablePureComponent<IEmojiSelector> { class EmojiSelector extends ImmutablePureComponent<IEmojiSelector> {
static defaultProps: Partial<IEmojiSelector> = { static defaultProps: Partial<IEmojiSelector> = {
onReact: () => () => {}, onReact: () => {},
onUnfocus: () => {}, onUnfocus: () => {},
visible: false, visible: false,
} }
@ -87,10 +87,10 @@ class EmojiSelector extends ImmutablePureComponent<IEmojiSelector> {
} }
} }
handleReact = (emoji: string) => () => { handleReact = (emoji: string) => (): void => {
const { onReact, focused, onUnfocus } = this.props; const { onReact, focused, onUnfocus } = this.props;
onReact(emoji)(); onReact(emoji);
if (focused) { if (focused) {
onUnfocus(); onUnfocus();

View file

@ -168,24 +168,28 @@ class StatusActionBar extends ImmutablePureComponent {
if (features.emojiReacts && isUserTouching()) { if (features.emojiReacts && isUserTouching()) {
if (this.state.emojiSelectorVisible) { if (this.state.emojiSelectorVisible) {
this.handleReactClick(meEmojiReact)(); this.handleReact(meEmojiReact);
} else { } else {
this.setState({ emojiSelectorVisible: true }); this.setState({ emojiSelectorVisible: true });
} }
} else { } 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 => { handleReactClick = emoji => {
return e => { return e => {
const { me, dispatch, onOpenUnauthorizedModal, status } = this.props; this.handleReact(emoji);
if (me) {
dispatch(simpleEmojiReact(status, emoji));
} else {
onOpenUnauthorizedModal('FAVOURITE');
}
this.setState({ emojiSelectorVisible: false });
}; };
} }
@ -667,7 +671,7 @@ class StatusActionBar extends ImmutablePureComponent {
onMouseLeave={this.handleLikeButtonLeave} onMouseLeave={this.handleLikeButtonLeave}
> >
<EmojiSelector <EmojiSelector
onReact={this.handleReactClick} onReact={this.handleReact}
visible={features.emojiReacts && emojiSelectorVisible} visible={features.emojiReacts && emojiSelectorVisible}
focused={emojiSelectorFocused} focused={emojiSelectorFocused}
onUnfocus={handleEmojiSelectorUnfocus} onUnfocus={handleEmojiSelectorUnfocus}