Page MenuHomePhabricator

D13160.id43617.diff
No OneTemporary

D13160.id43617.diff

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,31 @@
) => {
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
+ .filter(member => !member.isSender)
+ .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,
+ },
+ supportsAutoRetry: false,
+ recipients: {
+ type: 'some_users',
+ userIDs: recipientIDs,
+ },
+ });
+ return;
+ }
+
const { localID } = messageInfo;
invariant(
localID !== null && localID !== undefined,
@@ -1755,6 +1792,7 @@
const staffCanSee = useStaffCanSee();
const textMessageCreationSideEffectsFunc =
useMessageCreationSideEffectsFunc<RawTextMessageInfo>(messageTypes.TEXT);
+ const processAndSendDMOperation = useProcessAndSendDMOperation();
return (
<InputStateContainer
@@ -1769,6 +1807,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,31 @@
) {
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
+ .filter(member => !member.isSender)
+ .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,
+ },
+ supportsAutoRetry: false,
+ recipients: {
+ type: 'some_users',
+ userIDs: recipientIDs,
+ },
+ });
+ return;
+ }
+
const { localID } = messageInfo;
invariant(
localID !== null && localID !== undefined,
@@ -1678,6 +1715,7 @@
const dispatchActionPromise = useDispatchActionPromise();
const modalContext = useModalContext();
const identityContext = React.useContext(IdentityClientContext);
+ const processAndSendDMOperation = useProcessAndSendDMOperation();
const [sendCallbacks, setSendCallbacks] = React.useState<
$ReadOnlyArray<() => mixed>,
@@ -1710,6 +1748,7 @@
deleteUpload={callDeleteUpload}
sendMultimediaMessage={callSendMultimediaMessage}
sendTextMessage={callSendTextMessage}
+ processAndSendDMOperation={processAndSendDMOperation}
newThinThread={callNewThinThread}
dispatch={dispatch}
dispatchActionPromise={dispatchActionPromise}

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 19, 5:59 PM (17 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2324319
Default Alt Text
D13160.id43617.diff (6 KB)

Event Timeline