MCPcopy Create free account
hub / github.com/CommE2E/comm / sendTextMessage

Method sendTextMessage

web/input/input-state-container.react.js:1306–1400  ·  view source on GitHub ↗
(
    messageInfo: RawTextMessageInfo,
    inputThreadInfo: ThreadInfo,
    parentThreadInfo: ?ThreadInfo,
  )

Source from the content-addressed store, hash-verified

1304 };
1305
1306 async sendTextMessage(
1307 messageInfo: RawTextMessageInfo,
1308 inputThreadInfo: ThreadInfo,
1309 parentThreadInfo: ?ThreadInfo,
1310 ) {
1311 this.props.sendCallbacks.forEach(callback => callback());
1312
1313 const { localID } = messageInfo;
1314 invariant(
1315 localID !== null && localID !== undefined,
1316 'localID should be set',
1317 );
1318 if (threadIsPendingSidebar(inputThreadInfo.id)) {
1319 this.pendingSidebarCreationMessageLocalIDs.add(localID);
1320 }
1321
1322 if (!threadIsPending(inputThreadInfo.id)) {
1323 void this.props.dispatchActionPromise(
1324 sendTextMessageActionTypes,
1325 this.sendTextMessageAction(
1326 messageInfo,
1327 inputThreadInfo,
1328 parentThreadInfo,
1329 ),
1330 undefined,
1331 messageInfo,
1332 );
1333 return;
1334 }
1335
1336 this.props.dispatch({
1337 type: sendTextMessageActionTypes.started,
1338 payload: messageInfo,
1339 });
1340
1341 let threadInfo = inputThreadInfo;
1342 const { viewerID } = this.props;
1343 if (viewerID && threadTypeIsSidebar(inputThreadInfo.type)) {
1344 invariant(parentThreadInfo, 'sidebar should have parent');
1345 threadInfo = patchThreadInfoToIncludeMentionedMembersOfParent(
1346 inputThreadInfo,
1347 parentThreadInfo,
1348 messageInfo.text,
1349 viewerID,
1350 );
1351 if (threadInfo !== inputThreadInfo) {
1352 this.props.dispatch({
1353 type: updateNavInfoActionType,
1354 payload: { pendingThread: threadInfo },
1355 });
1356 }
1357 }
1358
1359 let threadCreationResult = null;
1360 try {
1361 threadCreationResult = await this.startThreadCreation(threadInfo);
1362 } catch (e) {
1363 const exceptionMessage = getMessageForException(e) ?? '';

Calls 11

sendTextMessageActionMethod · 0.95
startThreadCreationMethod · 0.95
threadIsPendingSidebarFunction · 0.90
threadIsPendingFunction · 0.90
threadTypeIsSidebarFunction · 0.90
getMessageForExceptionFunction · 0.90
forEachMethod · 0.65
addMethod · 0.65
deleteMethod · 0.65
callbackFunction · 0.50

Tested by

no test coverage detected