Page MenuHomePhabricator

D8711.id30366.diff
No OneTemporary

D8711.id30366.diff

diff --git a/web/chat/message-tooltip.react.js b/web/chat/message-tooltip.react.js
--- a/web/chat/message-tooltip.react.js
+++ b/web/chat/message-tooltip.react.js
@@ -173,20 +173,19 @@
const nextLocalID = useSelector(state => state.nextLocalID);
const localID = `${localIDPrefix}${nextLocalID}`;
- const sendReaction = useSendReaction(messageInfo.id, localID, threadInfo.id);
+ const sendReaction = useSendReaction(
+ messageInfo.id,
+ localID,
+ threadInfo.id,
+ reactions,
+ );
const onEmojiSelect = React.useCallback(
emoji => {
const reactionInput = emoji.native;
-
- const viewerReacted = reactions[reactionInput]
- ? reactions[reactionInput].viewerReacted
- : false;
- const action = viewerReacted ? 'remove_reaction' : 'add_reaction';
-
- sendReaction(reactionInput, action);
+ sendReaction(reactionInput);
},
- [sendReaction, reactions],
+ [sendReaction],
);
const emojiKeyboard = React.useMemo(() => {
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
@@ -8,6 +8,7 @@
sendReactionMessageActionTypes,
} from 'lib/actions/message-actions.js';
import { useModalContext } from 'lib/components/modal-provider.react.js';
+import type { ReactionInfo } from 'lib/selectors/chat-selectors';
import { messageTypes } from 'lib/types/message-types-enum.js';
import type { RawReactionMessageInfo } from 'lib/types/messages/reaction.js';
import {
@@ -28,7 +29,8 @@
messageID: ?string,
localID: string,
threadID: string,
-): (reaction: string, action: 'add_reaction' | 'remove_reaction') => mixed {
+ reactions: ReactionInfo,
+): (reaction: string) => mixed {
const { pushModal } = useModalContext();
const viewerID = useSelector(
@@ -39,13 +41,18 @@
const dispatchActionPromise = useDispatchActionPromise();
return React.useCallback(
- (reaction, action) => {
+ reaction => {
if (!messageID) {
return;
}
invariant(viewerID, 'viewerID should be set');
+ const viewerReacted = reactions[reaction]
+ ? reactions[reaction].viewerReacted
+ : false;
+ const action = viewerReacted ? 'remove_reaction' : 'add_reaction';
+
const reactionMessagePromise = (async () => {
try {
const result = await callSendReactionMessage({
@@ -97,6 +104,7 @@
[
messageID,
viewerID,
+ reactions,
threadID,
localID,
dispatchActionPromise,

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 3:42 PM (19 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2570370
Default Alt Text
D8711.id30366.diff (2 KB)

Event Timeline