Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3516086
D13244.id43890.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
13 KB
Referenced Files
None
Subscribers
None
D13244.id43890.diff
View Options
diff --git a/lib/shared/thread-actions-utils.js b/lib/shared/thread-actions-utils.js
--- a/lib/shared/thread-actions-utils.js
+++ b/lib/shared/thread-actions-utils.js
@@ -20,10 +20,13 @@
import {
threadTypes,
assertThinThreadType,
+ assertThickThreadType,
+ threadTypeIsThick,
} from '../types/thread-types-enum.js';
import type {
ChangeThreadSettingsPayload,
ClientNewThinThreadRequest,
+ NewThickThreadRequest,
NewThreadResult,
} from '../types/thread-types.js';
import type { DispatchActionPromise } from '../utils/redux-promise-utils.js';
@@ -51,6 +54,7 @@
+threadInfo: ThreadInfo,
+dispatchActionPromise: DispatchActionPromise,
+createNewThinThread: ClientNewThinThreadRequest => Promise<NewThreadResult>,
+ +createNewThickThread: NewThickThreadRequest => Promise<string>,
+sourceMessageID: ?string,
+viewerID: ?string,
+handleError?: () => mixed,
@@ -61,6 +65,7 @@
threadInfo,
dispatchActionPromise,
createNewThinThread,
+ createNewThickThread,
sourceMessageID,
viewerID,
calendarQuery,
@@ -69,44 +74,86 @@
return threadInfo.id;
}
+ let newThreadID;
+
const otherMemberIDs = threadOtherMembers(threadInfo.members, viewerID).map(
member => member.id,
);
let resultPromise;
- if (threadInfo.type !== threadTypes.SIDEBAR) {
- invariant(
- otherMemberIDs.length > 0,
- 'otherMemberIDs should not be empty for threads',
- );
- // TODO add support for thickThreadTypes in ENG-8442
- const type = assertThinThreadType(pendingThreadType(otherMemberIDs.length));
+ if (threadInfo.type === threadTypes.SIDEBAR) {
invariant(
- type !== 5, // Flow does not recognize that threadTypes.SIDEBAR is 5
- 'pendingThreadType should not return SIDEBAR',
+ sourceMessageID,
+ 'sourceMessageID should be set when creating a sidebar',
);
resultPromise = createNewThinThread({
- type,
+ type: threadTypes.SIDEBAR,
initialMemberIDs: otherMemberIDs,
color: threadInfo.color,
+ sourceMessageID,
+ parentThreadID: threadInfo.parentThreadID,
+ name: threadInfo.name,
calendarQuery,
});
- } else {
+ void dispatchActionPromise(newThreadActionTypes, resultPromise);
+ const result = await resultPromise;
+ newThreadID = result.newThreadID;
+ } else if (threadInfo.type === threadTypes.THICK_SIDEBAR) {
invariant(
sourceMessageID,
'sourceMessageID should be set when creating a sidebar',
);
- resultPromise = createNewThinThread({
- type: threadTypes.SIDEBAR,
+ invariant(
+ threadInfo.parentThreadID,
+ 'parentThreadID should be set when creating a sidebar',
+ );
+ newThreadID = await createNewThickThread({
+ type: threadTypes.THICK_SIDEBAR,
initialMemberIDs: otherMemberIDs,
color: threadInfo.color,
sourceMessageID,
parentThreadID: threadInfo.parentThreadID,
name: threadInfo.name,
- calendarQuery,
});
+ } else {
+ invariant(
+ otherMemberIDs.length > 0,
+ 'otherMemberIDs should not be empty for threads',
+ );
+ if (threadTypeIsThick(threadInfo.type)) {
+ const type = assertThickThreadType(
+ pendingThreadType(otherMemberIDs.length),
+ );
+
+ invariant(
+ type !== 16,
+ // Flow does not recognize that threadTypes.THICK_SIDEBAR is 16
+ 'pendingThreadType should not return THICK_SIDEBAR',
+ );
+ newThreadID = await createNewThickThread({
+ type,
+ initialMemberIDs: otherMemberIDs,
+ color: threadInfo.color,
+ });
+ } else {
+ const type = assertThinThreadType(
+ pendingThreadType(otherMemberIDs.length),
+ );
+
+ invariant(
+ type !== 5, // Flow does not recognize that threadTypes.SIDEBAR is 5
+ 'pendingThreadType should not return SIDEBAR',
+ );
+ resultPromise = createNewThinThread({
+ type,
+ initialMemberIDs: otherMemberIDs,
+ color: threadInfo.color,
+ calendarQuery,
+ });
+ void dispatchActionPromise(newThreadActionTypes, resultPromise);
+ const result = await resultPromise;
+ newThreadID = result.newThreadID;
+ }
}
- void dispatchActionPromise(newThreadActionTypes, resultPromise);
- const { newThreadID } = await resultPromise;
return newThreadID;
}
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
@@ -30,6 +30,7 @@
useBlobServiceUpload,
} from 'lib/actions/upload-actions.js';
import commStaffCommunity from 'lib/facts/comm-staff-community.js';
+import { useNewThickThread } from 'lib/hooks/thread-search-hooks.js';
import type {
CallSingleKeyserverEndpointOptions,
CallSingleKeyserverEndpointResponse,
@@ -97,6 +98,7 @@
import {
type ClientNewThinThreadRequest,
type NewThreadResult,
+ type NewThickThreadRequest,
} from 'lib/types/thread-types.js';
import { getConfig } from 'lib/utils/config.js';
import { cloneError, getMessageForException } from 'lib/utils/errors.js';
@@ -171,6 +173,7 @@
+newThinThread: (
request: ClientNewThinThreadRequest,
) => Promise<NewThreadResult>,
+ +newThickThread: (request: NewThickThreadRequest) => Promise<string>,
+textMessageCreationSideEffectsFunc: CreationSideEffectsFunc<RawTextMessageInfo>,
};
type State = {
@@ -464,6 +467,31 @@
);
};
+ async processAndSendDMOperation(
+ messageInfo: RawTextMessageInfo,
+ inputThreadInfo: ThreadInfo,
+ ) {
+ 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: 'all_thread_members',
+ threadID:
+ inputThreadInfo.type === thickThreadTypes.THICK_SIDEBAR &&
+ inputThreadInfo.parentThreadID
+ ? inputThreadInfo.parentThreadID
+ : inputThreadInfo.id,
+ },
+ });
+ }
+
sendTextMessage = async (
messageInfo: RawTextMessageInfo,
inputThreadInfo: ThreadInfo,
@@ -471,31 +499,6 @@
) => {
this.sendCallbacks.forEach(callback => callback());
- // TODO: this should be update according to thread creation logic
- // (ENG-8567)
- if (threadTypeIsThick(inputThreadInfo.type)) {
- 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: 'all_thread_members',
- threadID:
- inputThreadInfo.type === thickThreadTypes.THICK_SIDEBAR &&
- inputThreadInfo.parentThreadID
- ? inputThreadInfo.parentThreadID
- : inputThreadInfo.id,
- },
- });
- return;
- }
-
const { localID } = messageInfo;
invariant(
localID !== null && localID !== undefined,
@@ -506,6 +509,10 @@
}
if (!threadIsPending(inputThreadInfo.id)) {
+ if (threadTypeIsThick(inputThreadInfo.type)) {
+ void this.processAndSendDMOperation(messageInfo, inputThreadInfo);
+ return;
+ }
void this.props.dispatchActionPromise(
sendTextMessageActionTypes,
this.sendTextMessageAction(
@@ -570,6 +577,11 @@
id: newThreadID,
};
+ if (threadTypeIsThick(inputThreadInfo.type)) {
+ void this.processAndSendDMOperation(newMessageInfo, newThreadInfo);
+ return;
+ }
+
void this.props.dispatchActionPromise(
sendTextMessageActionTypes,
this.sendTextMessageAction(
@@ -593,6 +605,7 @@
threadInfo,
dispatchActionPromise: this.props.dispatchActionPromise,
createNewThinThread: this.props.newThinThread,
+ createNewThickThread: this.props.newThickThread,
sourceMessageID: threadInfo.sourceMessageID,
viewerID: this.props.viewerID,
calendarQuery,
@@ -1787,6 +1800,7 @@
const callSendMultimediaMessage = useSendMultimediaMessage();
const callSendTextMessage = useSendTextMessage();
const callNewThinThread = useNewThinThread();
+ const callNewThickThread = useNewThickThread();
const dispatchActionPromise = useDispatchActionPromise();
const dispatch = useDispatch();
const mediaReportsEnabled = useIsReportEnabled('mediaReports');
@@ -1810,6 +1824,7 @@
sendTextMessage={callSendTextMessage}
processAndSendDMOperation={processAndSendDMOperation}
newThinThread={callNewThinThread}
+ newThickThread={callNewThickThread}
dispatchActionPromise={dispatchActionPromise}
dispatch={dispatch}
staffCanSee={staffCanSee}
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
@@ -40,6 +40,7 @@
} from 'lib/components/modal-provider.react.js';
import blobService from 'lib/facts/blob-service.js';
import commStaffCommunity from 'lib/facts/comm-staff-community.js';
+import { useNewThickThread } from 'lib/hooks/thread-search-hooks.js';
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';
@@ -94,6 +95,7 @@
import {
type ClientNewThinThreadRequest,
type NewThreadResult,
+ type NewThickThreadRequest,
} from 'lib/types/thread-types.js';
import {
blobHashFromBlobServiceURI,
@@ -165,6 +167,7 @@
+newThinThread: (
request: ClientNewThinThreadRequest,
) => Promise<NewThreadResult>,
+ +newThickThread: (request: NewThickThreadRequest) => Promise<string>,
+pushModal: PushModal,
+sendCallbacks: $ReadOnlyArray<() => mixed>,
+registerSendCallback: (() => mixed) => void,
@@ -597,6 +600,7 @@
threadInfo,
dispatchActionPromise: this.props.dispatchActionPromise,
createNewThinThread: this.props.newThinThread,
+ createNewThickThread: this.props.newThickThread,
sourceMessageID: threadInfo.sourceMessageID,
viewerID: this.props.viewerID,
calendarQuery,
@@ -1274,6 +1278,31 @@
);
}
+ async processAndSendDMOperation(
+ messageInfo: RawTextMessageInfo,
+ inputThreadInfo: ThreadInfo,
+ ) {
+ 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: 'all_thread_members',
+ threadID:
+ inputThreadInfo.type === thickThreadTypes.THICK_SIDEBAR &&
+ inputThreadInfo.parentThreadID
+ ? inputThreadInfo.parentThreadID
+ : inputThreadInfo.id,
+ },
+ });
+ }
+
async sendTextMessage(
messageInfo: RawTextMessageInfo,
inputThreadInfo: ThreadInfo,
@@ -1281,31 +1310,6 @@
) {
this.props.sendCallbacks.forEach(callback => callback());
- // TODO: this should be update according to thread creation logic
- // (ENG-8567)
- if (threadTypeIsThick(inputThreadInfo.type)) {
- 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: 'all_thread_members',
- threadID:
- inputThreadInfo.type === thickThreadTypes.THICK_SIDEBAR &&
- inputThreadInfo.parentThreadID
- ? inputThreadInfo.parentThreadID
- : inputThreadInfo.id,
- },
- });
- return;
- }
-
const { localID } = messageInfo;
invariant(
localID !== null && localID !== undefined,
@@ -1316,6 +1320,10 @@
}
if (!threadIsPending(inputThreadInfo.id)) {
+ if (threadTypeIsThick(inputThreadInfo.type)) {
+ void this.processAndSendDMOperation(messageInfo, inputThreadInfo);
+ return;
+ }
void this.props.dispatchActionPromise(
sendTextMessageActionTypes,
this.sendTextMessageAction(
@@ -1380,6 +1388,11 @@
id: newThreadID,
};
+ if (threadTypeIsThick(inputThreadInfo.type)) {
+ void this.processAndSendDMOperation(newMessageInfo, newThreadInfo);
+ return;
+ }
+
void this.props.dispatchActionPromise(
sendTextMessageActionTypes,
this.sendTextMessageAction(
@@ -1712,6 +1725,7 @@
const callSendMultimediaMessage = useLegacySendMultimediaMessage();
const callSendTextMessage = useSendTextMessage();
const callNewThinThread = useNewThinThread();
+ const callNewThickThread = useNewThickThread();
const dispatch = useDispatch();
const dispatchActionPromise = useDispatchActionPromise();
const modalContext = useModalContext();
@@ -1751,6 +1765,7 @@
sendTextMessage={callSendTextMessage}
processAndSendDMOperation={processAndSendDMOperation}
newThinThread={callNewThinThread}
+ newThickThread={callNewThickThread}
dispatch={dispatch}
dispatchActionPromise={dispatchActionPromise}
pushModal={modalContext.pushModal}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 12:08 PM (18 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2694648
Default Alt Text
D13244.id43890.diff (13 KB)
Attached To
Mode
D13244: [lib][web][native] Update createRealThreadFromPendingThread to handle thick thread creation
Attached
Detach File
Event Timeline
Log In to Comment