kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Remove bloat
rodzic
320afaed1c
commit
3d78a1cf16
|
@ -4,7 +4,7 @@ import { simpleEmojiReact } from 'soapbox/actions/emoji-reacts';
|
||||||
import { openModal } from 'soapbox/actions/modals';
|
import { openModal } from 'soapbox/actions/modals';
|
||||||
import { EmojiSelector, Portal } from 'soapbox/components/ui';
|
import { EmojiSelector, Portal } from 'soapbox/components/ui';
|
||||||
import { useAppDispatch, useAppSelector, useOwnAccount, useSoapboxConfig } from 'soapbox/hooks';
|
import { useAppDispatch, useAppSelector, useOwnAccount, useSoapboxConfig } from 'soapbox/hooks';
|
||||||
import { isUserTouching } from 'soapbox/is-mobile';
|
// import { isUserTouching } from 'soapbox/is-mobile';
|
||||||
import { getReactForStatus } from 'soapbox/utils/emoji-reacts';
|
import { getReactForStatus } from 'soapbox/utils/emoji-reacts';
|
||||||
|
|
||||||
interface IStatusReactionWrapper {
|
interface IStatusReactionWrapper {
|
||||||
|
@ -34,31 +34,31 @@ const StatusReactionWrapper: React.FC<IStatusReactionWrapper> = ({ statusId, chi
|
||||||
|
|
||||||
if (!status) return null;
|
if (!status) return null;
|
||||||
|
|
||||||
const handleMouseEnter = () => {
|
// const handleMouseEnter = () => {
|
||||||
if (timeout.current) {
|
// if (timeout.current) {
|
||||||
clearTimeout(timeout.current);
|
// clearTimeout(timeout.current);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!isUserTouching()) {
|
// if (!isUserTouching()) {
|
||||||
setVisible(true);
|
// setVisible(true);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
const handleMouseLeave = () => {
|
// const handleMouseLeave = () => {
|
||||||
if (timeout.current) {
|
// if (timeout.current) {
|
||||||
clearTimeout(timeout.current);
|
// clearTimeout(timeout.current);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Unless the user is touching, delay closing the emoji selector briefly
|
// // Unless the user is touching, delay closing the emoji selector briefly
|
||||||
// so the user can move the mouse diagonally to make a selection.
|
// // so the user can move the mouse diagonally to make a selection.
|
||||||
if (isUserTouching()) {
|
// if (isUserTouching()) {
|
||||||
setVisible(false);
|
// setVisible(false);
|
||||||
} else {
|
// } else {
|
||||||
timeout.current = setTimeout(() => {
|
// timeout.current = setTimeout(() => {
|
||||||
setVisible(false);
|
// setVisible(false);
|
||||||
}, 500);
|
// }, 500);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
const handleReact = (emoji: string, custom?: string): void => {
|
const handleReact = (emoji: string, custom?: string): void => {
|
||||||
if (ownAccount) {
|
if (ownAccount) {
|
||||||
|
@ -71,21 +71,9 @@ const StatusReactionWrapper: React.FC<IStatusReactionWrapper> = ({ statusId, chi
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClick: React.EventHandler<React.MouseEvent> = e => {
|
const handleClick: React.EventHandler<React.MouseEvent> = e => {
|
||||||
const meEmojiReact = getReactForStatus(status, soapboxConfig.allowedEmoji)?.get('name') || '👍';
|
const meEmojiReact = getReactForStatus(status, soapboxConfig.allowedEmoji)?.get('name') || '⚡';
|
||||||
|
|
||||||
if (isUserTouching()) {
|
handleReact(meEmojiReact);
|
||||||
if (ownAccount) {
|
|
||||||
if (visible) {
|
|
||||||
handleReact(meEmojiReact);
|
|
||||||
} else {
|
|
||||||
setVisible(true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
handleUnauthorized();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
handleReact(meEmojiReact);
|
|
||||||
}
|
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
@ -99,7 +87,7 @@ const StatusReactionWrapper: React.FC<IStatusReactionWrapper> = ({ statusId, chi
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='relative' onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>
|
<div className='relative'>
|
||||||
{React.cloneElement(children, {
|
{React.cloneElement(children, {
|
||||||
onClick: handleClick,
|
onClick: handleClick,
|
||||||
ref: setReferenceElement,
|
ref: setReferenceElement,
|
||||||
|
|
Ładowanie…
Reference in New Issue