EmojiReacts: consistent hover behavior, isUserTouching()

profile-avatar-switcher
Alex Gleason 2021-10-15 17:56:03 -05:00
rodzic 7f4a467c16
commit 1a6b61c248
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 4 dodań i 5 usunięć

Wyświetl plik

@ -15,6 +15,7 @@ import { getReactForStatus, reduceEmoji } from 'soapbox/utils/emoji_reacts';
import { simpleEmojiReact } from 'soapbox/actions/emoji_reacts'; import { simpleEmojiReact } from 'soapbox/actions/emoji_reacts';
import { List as ImmutableList } from 'immutable'; import { List as ImmutableList } from 'immutable';
import { getFeatures } from 'soapbox/utils/features'; import { getFeatures } from 'soapbox/utils/features';
import { isUserTouching } from 'soapbox/is_mobile';
const messages = defineMessages({ const messages = defineMessages({
delete: { id: 'status.delete', defaultMessage: 'Delete' }, delete: { id: 'status.delete', defaultMessage: 'Delete' },
@ -133,12 +134,10 @@ class StatusActionBar extends ImmutablePureComponent {
}); });
} }
isMobile = () => window.matchMedia('only screen and (max-width: 895px)').matches;
handleLikeButtonHover = e => { handleLikeButtonHover = e => {
const { features } = this.props; const { features } = this.props;
if (features.emojiReacts && !this.isMobile()) { if (features.emojiReacts && !isUserTouching()) {
this.setState({ emojiSelectorVisible: true }); this.setState({ emojiSelectorVisible: true });
} }
} }
@ -146,7 +145,7 @@ class StatusActionBar extends ImmutablePureComponent {
handleLikeButtonLeave = e => { handleLikeButtonLeave = e => {
const { features } = this.props; const { features } = this.props;
if (features.emojiReacts && !this.isMobile()) { if (features.emojiReacts && !isUserTouching()) {
this.setState({ emojiSelectorVisible: false }); this.setState({ emojiSelectorVisible: false });
} }
} }
@ -155,7 +154,7 @@ class StatusActionBar extends ImmutablePureComponent {
const { features } = this.props; const { features } = this.props;
const meEmojiReact = getReactForStatus(this.props.status, this.props.allowedEmoji) || '👍'; const meEmojiReact = getReactForStatus(this.props.status, this.props.allowedEmoji) || '👍';
if (features.emojiReacts && this.isMobile()) { if (features.emojiReacts && isUserTouching()) {
if (this.state.emojiSelectorVisible) { if (this.state.emojiSelectorVisible) {
this.handleReactClick(meEmojiReact)(); this.handleReactClick(meEmojiReact)();
} else { } else {