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 {
allowedEmoji: ImmutableList<string>,
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<IEmojiSelector> {
static defaultProps: Partial<IEmojiSelector> = {
onReact: () => () => {},
onReact: () => {},
onUnfocus: () => {},
visible: false,
}
@ -87,10 +87,10 @@ class EmojiSelector extends ImmutablePureComponent<IEmojiSelector> {
}
}
handleReact = (emoji: string) => () => {
handleReact = (emoji: string) => (): void => {
const { onReact, focused, onUnfocus } = this.props;
onReact(emoji)();
onReact(emoji);
if (focused) {
onUnfocus();

View file

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