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

Class InputStateContainer

native/input/input-state-container.react.js:189–1742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187};
188
189class InputStateContainer extends React.PureComponent<Props, State> {
190 state: State = {
191 pendingUploads: {},
192 reply: null,
193 };
194 sendCallbacks: Array<() => void> = [];
195 activeURIs: Map<string, ActiveURI> = new Map();
196 editInputBarCallbacks: Array<
197 (params: EditInputBarMessageParameters) => void,
198 > = [];
199 scrollToMessageCallbacks: Array<(messageID: string) => void> = [];
200 pendingThreadCreations: Map<
201 string,
202 Promise<{
203 +threadID: string,
204 +threadType: ThreadType,
205 }>,
206 > = new Map();
207 pendingThreadUpdateHandlers: Map<string, (ThreadInfo) => mixed> = new Map();
208
209 // When the user sends a multimedia message that triggers the creation of a
210 // sidebar, the sidebar gets created right away, but the message needs to wait
211 // for the uploads to complete before sending. We use this Set to track the
212 // message localIDs that need sidebarCreation: true.
213 pendingSidebarCreationMessageLocalIDs: Set<string> = new Set();
214
215 static getCompletedUploads(props: Props, state: State): CompletedUploads {
216 const completedUploads: WritableCompletedUploads = {};
217 for (const localMessageID in state.pendingUploads) {
218 const messagePendingUploads = state.pendingUploads[localMessageID];
219 const rawMessageInfo = props.messageStoreMessages[localMessageID];
220 if (!rawMessageInfo) {
221 continue;
222 }
223 invariant(
224 rawMessageInfo.type === messageTypes.IMAGES ||
225 rawMessageInfo.type === messageTypes.MULTIMEDIA,
226 `rawMessageInfo ${localMessageID} should be multimedia`,
227 );
228
229 let allUploadsComplete = true;
230 const completedUploadIDs = new Set(Object.keys(messagePendingUploads));
231 for (const singleMedia of rawMessageInfo.media) {
232 if (isLocalUploadID(singleMedia.id)) {
233 allUploadsComplete = false;
234 completedUploadIDs.delete(singleMedia.id);
235 }
236 const { thumbnailID } = singleMedia;
237 if (thumbnailID && isLocalUploadID(thumbnailID)) {
238 allUploadsComplete = false;
239 completedUploadIDs.delete(thumbnailID);
240 }
241 }
242
243 if (allUploadsComplete) {
244 completedUploads[localMessageID] = null;
245 } else if (completedUploadIDs.size > 0) {
246 completedUploads[localMessageID] = completedUploadIDs;

Callers

nothing calls this directly

Calls 15

sendTextMessageActionMethod · 0.95
startThreadCreationMethod · 0.95
uploadFilesMethod · 0.95
sendTextMessageMethod · 0.95
valuesFunction · 0.90
threadIsPendingSidebarFunction · 0.90
threadIsPendingFunction · 0.90
threadTypeIsSidebarFunction · 0.90
getMessageForExceptionFunction · 0.90

Tested by

no test coverage detected