EmojiSelector: fix onReact prop
This commit is contained in:
parent
52982706fe
commit
5e8472e29d
2 changed files with 18 additions and 14 deletions
|
@ -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();
|
||||||
|
|
|
@ -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}
|
||||||
|
|
Loading…
Reference in a new issue