EmojiButtonWrapper: handle click
This commit is contained in:
parent
0912700d15
commit
ba5c3b224c
3 changed files with 19 additions and 2 deletions
|
@ -7,6 +7,8 @@ import { simpleEmojiReact } from 'soapbox/actions/emoji_reacts';
|
||||||
import { openModal } from 'soapbox/actions/modals';
|
import { openModal } from 'soapbox/actions/modals';
|
||||||
import EmojiSelector from 'soapbox/components/ui/emoji-selector/emoji-selector';
|
import EmojiSelector from 'soapbox/components/ui/emoji-selector/emoji-selector';
|
||||||
import { useAppSelector, useOwnAccount, useSoapboxConfig } from 'soapbox/hooks';
|
import { useAppSelector, useOwnAccount, useSoapboxConfig } from 'soapbox/hooks';
|
||||||
|
import { isUserTouching } from 'soapbox/is_mobile';
|
||||||
|
import { getReactForStatus } from 'soapbox/utils/emoji_reacts';
|
||||||
|
|
||||||
interface IEmojiButtonWrapper {
|
interface IEmojiButtonWrapper {
|
||||||
statusId: string,
|
statusId: string,
|
||||||
|
@ -62,6 +64,22 @@ const EmojiButtonWrapper: React.FC<IEmojiButtonWrapper> = ({ statusId, children
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleClick: React.EventHandler<React.MouseEvent> = e => {
|
||||||
|
const meEmojiReact = getReactForStatus(status, soapboxConfig.allowedEmoji) || '👍';
|
||||||
|
|
||||||
|
if (isUserTouching()) {
|
||||||
|
if (visible) {
|
||||||
|
handleReact(meEmojiReact);
|
||||||
|
} else {
|
||||||
|
setVisible(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
handleReact(meEmojiReact);
|
||||||
|
}
|
||||||
|
|
||||||
|
e.stopPropagation();
|
||||||
|
};
|
||||||
|
|
||||||
// const handleUnfocus: React.EventHandler<React.KeyboardEvent> = () => {
|
// const handleUnfocus: React.EventHandler<React.KeyboardEvent> = () => {
|
||||||
// setFocused(false);
|
// setFocused(false);
|
||||||
// };
|
// };
|
||||||
|
@ -87,6 +105,7 @@ const EmojiButtonWrapper: React.FC<IEmojiButtonWrapper> = ({ statusId, children
|
||||||
return (
|
return (
|
||||||
<div onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>
|
<div onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>
|
||||||
{React.cloneElement(children, {
|
{React.cloneElement(children, {
|
||||||
|
onClick: handleClick,
|
||||||
ref,
|
ref,
|
||||||
})}
|
})}
|
||||||
|
|
||||||
|
|
|
@ -645,7 +645,6 @@ class StatusActionBar extends ImmutablePureComponent<IStatusActionBar, IStatusAc
|
||||||
title={meEmojiTitle}
|
title={meEmojiTitle}
|
||||||
icon={require('@tabler/icons/icons/thumb-up.svg')}
|
icon={require('@tabler/icons/icons/thumb-up.svg')}
|
||||||
color='accent'
|
color='accent'
|
||||||
onClick={this.handleLikeButtonClick}
|
|
||||||
active={Boolean(meEmojiReact)}
|
active={Boolean(meEmojiReact)}
|
||||||
count={emojiReactCount}
|
count={emojiReactCount}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -588,7 +588,6 @@ class ActionBar extends React.PureComponent<IActionBar, IActionBarState> {
|
||||||
'fill-accent-300': Boolean(meEmojiReact),
|
'fill-accent-300': Boolean(meEmojiReact),
|
||||||
})}
|
})}
|
||||||
text={meEmojiTitle}
|
text={meEmojiTitle}
|
||||||
onClick={this.handleLikeButtonClick}
|
|
||||||
/>
|
/>
|
||||||
</EmojiButtonWrapper>
|
</EmojiButtonWrapper>
|
||||||
) : (
|
) : (
|
||||||
|
|
Loading…
Reference in a new issue