Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3367037
D13160.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D13160.diff
View Options
diff --git a/native/input/input-state-container.react.js b/native/input/input-state-container.react.js
--- a/native/input/input-state-container.react.js
+++ b/native/input/input-state-container.react.js
@@ -5,6 +5,7 @@
import * as React from 'react';
import { Platform } from 'react-native';
import { createSelector } from 'reselect';
+import uuid from 'uuid';
import type {
SendMultimediaMessageInput,
@@ -44,6 +45,11 @@
combineLoadingStatuses,
createLoadingStatusSelector,
} from 'lib/selectors/loading-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 {
createMediaMessageInfo,
useMessageCreationSideEffectsFunc,
@@ -83,7 +89,10 @@
type ClientMediaMissionReportCreationRequest,
reportTypes,
} from 'lib/types/report-types.js';
-import { threadTypeIsSidebar } from 'lib/types/thread-types-enum.js';
+import {
+ threadTypeIsThick,
+ threadTypeIsSidebar,
+} from 'lib/types/thread-types-enum.js';
import {
type ClientNewThinThreadRequest,
type NewThreadResult,
@@ -155,6 +164,9 @@
input: SendMultimediaMessageInput,
) => Promise<SendMessageResult>,
+sendTextMessage: (input: SendTextMessageInput) => Promise<SendMessageResult>,
+ +processAndSendDMOperation: (
+ dmOperationSpecification: OutboundDMOperationSpecification,
+ ) => Promise<void>,
+newThinThread: (
request: ClientNewThinThreadRequest,
) => Promise<NewThreadResult>,
@@ -458,6 +470,28 @@
) => {
this.sendCallbacks.forEach(callback => callback());
+ // TODO: this should be update according to thread creation logic
+ // (ENG-8567)
+ if (threadTypeIsThick(inputThreadInfo.type)) {
+ const recipientIDs = inputThreadInfo.members.map(member => member.id);
+ void this.props.processAndSendDMOperation({
+ type: dmOperationSpecificationTypes.OUTBOUND,
+ op: {
+ type: 'send_text_message',
+ threadID: inputThreadInfo.id,
+ creatorID: messageInfo.creatorID,
+ time: Date.now(),
+ messageID: uuid.v4(),
+ text: messageInfo.text,
+ },
+ recipients: {
+ type: 'some_users',
+ userIDs: recipientIDs,
+ },
+ });
+ return;
+ }
+
const { localID } = messageInfo;
invariant(
localID !== null && localID !== undefined,
@@ -1755,6 +1789,7 @@
const staffCanSee = useStaffCanSee();
const textMessageCreationSideEffectsFunc =
useMessageCreationSideEffectsFunc<RawTextMessageInfo>(messageTypes.TEXT);
+ const processAndSendDMOperation = useProcessAndSendDMOperation();
return (
<InputStateContainer
@@ -1769,6 +1804,7 @@
blobServiceUpload={callBlobServiceUpload}
sendMultimediaMessage={callSendMultimediaMessage}
sendTextMessage={callSendTextMessage}
+ processAndSendDMOperation={processAndSendDMOperation}
newThinThread={callNewThinThread}
dispatchActionPromise={dispatchActionPromise}
dispatch={dispatch}
diff --git a/web/input/input-state-container.react.js b/web/input/input-state-container.react.js
--- a/web/input/input-state-container.react.js
+++ b/web/input/input-state-container.react.js
@@ -9,6 +9,7 @@
import _memoize from 'lodash/memoize.js';
import * as React from 'react';
import { createSelector } from 'reselect';
+import uuid from 'uuid';
import type {
LegacySendMultimediaMessageInput,
@@ -42,6 +43,11 @@
import { useLegacyAshoatKeyserverCall } from 'lib/keyserver-conn/legacy-keyserver-call.js';
import { getNextLocalUploadID } from 'lib/media/media-utils.js';
import { pendingToRealizedThreadIDsSelector } from 'lib/selectors/thread-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 { IdentityClientContext } from 'lib/shared/identity-client-context.js';
import type { IdentityClientContextType } from 'lib/shared/identity-client-context.js';
import {
@@ -80,7 +86,10 @@
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { Dispatch } from 'lib/types/redux-types.js';
import { reportTypes } from 'lib/types/report-types.js';
-import { threadTypeIsSidebar } from 'lib/types/thread-types-enum.js';
+import {
+ threadTypeIsSidebar,
+ threadTypeIsThick,
+} from 'lib/types/thread-types-enum.js';
import {
type ClientNewThinThreadRequest,
type NewThreadResult,
@@ -149,6 +158,9 @@
input: LegacySendMultimediaMessageInput,
) => Promise<SendMessageResult>,
+sendTextMessage: (input: SendTextMessageInput) => Promise<SendMessageResult>,
+ +processAndSendDMOperation: (
+ dmOperationSpecification: OutboundDMOperationSpecification,
+ ) => Promise<void>,
+newThinThread: (
request: ClientNewThinThreadRequest,
) => Promise<NewThreadResult>,
@@ -1268,6 +1280,28 @@
) {
this.props.sendCallbacks.forEach(callback => callback());
+ // TODO: this should be update according to thread creation logic
+ // (ENG-8567)
+ if (threadTypeIsThick(inputThreadInfo.type)) {
+ const recipientIDs = inputThreadInfo.members.map(member => member.id);
+ void this.props.processAndSendDMOperation({
+ type: dmOperationSpecificationTypes.OUTBOUND,
+ op: {
+ type: 'send_text_message',
+ threadID: inputThreadInfo.id,
+ creatorID: messageInfo.creatorID,
+ time: Date.now(),
+ messageID: uuid.v4(),
+ text: messageInfo.text,
+ },
+ recipients: {
+ type: 'some_users',
+ userIDs: recipientIDs,
+ },
+ });
+ return;
+ }
+
const { localID } = messageInfo;
invariant(
localID !== null && localID !== undefined,
@@ -1678,6 +1712,7 @@
const dispatchActionPromise = useDispatchActionPromise();
const modalContext = useModalContext();
const identityContext = React.useContext(IdentityClientContext);
+ const processAndSendDMOperation = useProcessAndSendDMOperation();
const [sendCallbacks, setSendCallbacks] = React.useState<
$ReadOnlyArray<() => mixed>,
@@ -1710,6 +1745,7 @@
deleteUpload={callDeleteUpload}
sendMultimediaMessage={callSendMultimediaMessage}
sendTextMessage={callSendTextMessage}
+ processAndSendDMOperation={processAndSendDMOperation}
newThinThread={callNewThinThread}
dispatch={dispatch}
dispatchActionPromise={dispatchActionPromise}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 1:30 PM (22 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2584894
Default Alt Text
D13160.diff (6 KB)
Attached To
Mode
D13160: [lib] implement sending DM text messages
Attached
Detach File
Event Timeline
Log In to Comment