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

Class InputStateContainer

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

Source from the content-addressed store, hash-verified

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

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