Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3356963
D13174.id43756.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D13174.id43756.diff
View Options
diff --git a/native/chat/reaction-message-utils.js b/native/chat/reaction-message-utils.js
--- a/native/chat/reaction-message-utils.js
+++ b/native/chat/reaction-message-utils.js
@@ -2,16 +2,27 @@
import invariant from 'invariant';
import * as React from 'react';
+import uuid from 'uuid';
import {
useSendReactionMessage,
sendReactionMessageActionTypes,
} from 'lib/actions/message-actions.js';
import type { ReactionInfo } from 'lib/selectors/chat-selectors.js';
+import {
+ dmOperationSpecificationTypes,
+ type OutboundDMOperationSpecification,
+} from 'lib/shared/dm-ops/dm-op-utils.js';
+import { useProcessAndSendDMOperation } from 'lib/shared/dm-ops/process-dm-ops.js';
import { getNextLocalID } from 'lib/shared/message-utils.js';
+import type { DMSendReactionMessageOperation } from 'lib/types/dm-ops.js';
import { messageTypes } from 'lib/types/message-types-enum.js';
import type { RawReactionMessageInfo } from 'lib/types/messages/reaction.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types';
+import {
+ thickThreadTypes,
+ threadTypeIsThick,
+} from 'lib/types/thread-types-enum.js';
import { cloneError } from 'lib/utils/errors.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
@@ -33,6 +44,7 @@
const callSendReactionMessage = useSendReactionMessage();
const dispatchActionPromise = useDispatchActionPromise();
+ const processAndSendDMOperation = useProcessAndSendDMOperation();
return React.useCallback(
reaction => {
@@ -51,6 +63,33 @@
const threadID = threadInfo.id;
+ if (threadTypeIsThick(threadInfo.type)) {
+ const op: DMSendReactionMessageOperation = {
+ type: 'send_reaction_message',
+ threadID,
+ creatorID: viewerID,
+ time: Date.now(),
+ messageID: uuid.v4(),
+ targetMessageID: messageID,
+ reaction,
+ action,
+ };
+ const opSpecification: OutboundDMOperationSpecification = {
+ type: dmOperationSpecificationTypes.OUTBOUND,
+ op,
+ recipients: {
+ type: 'all_thread_members',
+ threadID:
+ threadInfo.type === thickThreadTypes.THICK_SIDEBAR &&
+ threadInfo.parentThreadID
+ ? threadInfo.parentThreadID
+ : threadInfo.id,
+ },
+ };
+ void processAndSendDMOperation(opSpecification);
+ return;
+ }
+
const reactionMessagePromise = (async () => {
try {
const result = await callSendReactionMessage({
@@ -107,7 +146,10 @@
viewerID,
reactions,
threadInfo.id,
+ threadInfo.type,
+ threadInfo.parentThreadID,
dispatchActionPromise,
+ processAndSendDMOperation,
callSendReactionMessage,
],
);
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
@@ -2,6 +2,7 @@
import invariant from 'invariant';
import * as React from 'react';
+import uuid from 'uuid';
import {
useSendReactionMessage,
@@ -10,10 +11,20 @@
import { useModalContext } from 'lib/components/modal-provider.react.js';
import type { CallSingleKeyserverEndpointResultInfoInterface } from 'lib/keyserver-conn/call-single-keyserver-endpoint.js';
import type { ReactionInfo } from 'lib/selectors/chat-selectors';
+import {
+ dmOperationSpecificationTypes,
+ type OutboundDMOperationSpecification,
+} from 'lib/shared/dm-ops/dm-op-utils.js';
+import { useProcessAndSendDMOperation } from 'lib/shared/dm-ops/process-dm-ops.js';
import { getNextLocalID } from 'lib/shared/message-utils.js';
+import { type DMSendReactionMessageOperation } from 'lib/types/dm-ops.js';
import { messageTypes } from 'lib/types/message-types-enum.js';
import type { RawReactionMessageInfo } from 'lib/types/messages/reaction.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
+import {
+ thickThreadTypes,
+ threadTypeIsThick,
+} from 'lib/types/thread-types-enum.js';
import { cloneError } from 'lib/utils/errors.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
@@ -38,6 +49,7 @@
const callSendReactionMessage = useSendReactionMessage();
const dispatchActionPromise = useDispatchActionPromise();
+ const processAndSendDMOperation = useProcessAndSendDMOperation();
return React.useCallback(
reaction => {
@@ -56,6 +68,33 @@
const threadID = threadInfo.id;
+ if (threadTypeIsThick(threadInfo.type)) {
+ const op: DMSendReactionMessageOperation = {
+ type: 'send_reaction_message',
+ threadID,
+ creatorID: viewerID,
+ time: Date.now(),
+ messageID: uuid.v4(),
+ targetMessageID: messageID,
+ reaction,
+ action,
+ };
+ const opSpecification: OutboundDMOperationSpecification = {
+ type: dmOperationSpecificationTypes.OUTBOUND,
+ op,
+ recipients: {
+ type: 'all_thread_members',
+ threadID:
+ threadInfo.type === thickThreadTypes.THICK_SIDEBAR &&
+ threadInfo.parentThreadID
+ ? threadInfo.parentThreadID
+ : threadInfo.id,
+ },
+ };
+ void processAndSendDMOperation(opSpecification);
+ return;
+ }
+
const reactionMessagePromise = (async () => {
try {
const result = await callSendReactionMessage({
@@ -113,7 +152,10 @@
viewerID,
reactions,
threadInfo.id,
+ threadInfo.type,
+ threadInfo.parentThreadID,
dispatchActionPromise,
+ processAndSendDMOperation,
callSendReactionMessage,
pushModal,
],
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 9:41 PM (20 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2577397
Default Alt Text
D13174.id43756.diff (5 KB)
Attached To
Mode
D13174: [web][native] update `useSendReaction` to send DMs reactions
Attached
Detach File
Event Timeline
Log In to Comment