diff --git a/web/chat/reaction-message-utils.js b/web/chat/reaction-message-utils.js --- a/web/chat/reaction-message-utils.js +++ b/web/chat/reaction-message-utils.js @@ -19,13 +19,13 @@ import Alert from '../modals/alert.react'; import { useSelector } from '../redux/redux-utils'; -function useOnClickReact( +function useOnClickReact(): ( messageID: ?string, localID: string, threadID: string, reaction: string, action: 'add_reaction' | 'remove_reaction', -): (event: SyntheticEvent) => mixed { +) => mixed { const { pushModal } = useModalContext(); const viewerID = useSelector( @@ -36,9 +36,7 @@ const dispatchActionPromise = useDispatchActionPromise(); return React.useCallback( - (event: SyntheticEvent) => { - event.preventDefault(); - + (messageID, localID, threadID, reaction, action) => { if (!messageID) { return; } @@ -93,17 +91,7 @@ startingPayload, ); }, - [ - messageID, - threadID, - localID, - viewerID, - reaction, - action, - dispatchActionPromise, - callSendReactionMessage, - pushModal, - ], + [viewerID, dispatchActionPromise, callSendReactionMessage, pushModal], ); } diff --git a/web/utils/tooltip-utils.js b/web/utils/tooltip-utils.js --- a/web/utils/tooltip-utils.js +++ b/web/utils/tooltip-utils.js @@ -466,12 +466,18 @@ const viewerReacted = !!reactions.get(reactionInput)?.viewerReacted; const action = viewerReacted ? 'remove_reaction' : 'add_reaction'; - const onClickReact = useOnClickReact( - messageInfo.id, - localID, - threadInfo.id, - reactionInput, - action, + const onClickReact = useOnClickReact(); + + const onClick = React.useCallback( + () => + onClickReact( + messageInfo.id, + localID, + threadInfo.id, + reactionInput, + action, + ), + [action, localID, messageInfo.id, onClickReact, threadInfo.id], ); const canCreateReactionFromMessage = useCanCreateReactionFromMessage( @@ -490,10 +496,10 @@ return { actionButtonContent: buttonContent, - onClick: onClickReact, + onClick, label: viewerReacted ? 'Unlike' : 'Like', }; - }, [canCreateReactionFromMessage, onClickReact, viewerReacted]); + }, [canCreateReactionFromMessage, onClick, viewerReacted]); } function useMessageTooltipActions(