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

Class InputStateContainer

web/input/input-state-container.react.js:189–1693  ·  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 textCursorPositions: {},
193 typeaheadState: {
194 canBeVisible: false,
195 keepUpdatingThreadMembers: true,
196 frozenUserMentionsCandidates: [],
197 frozenChatMentionsCandidates: {},
198 moveChoiceUp: null,
199 moveChoiceDown: null,
200 close: null,
201 accept: null,
202 },
203 };
204 replyCallbacks: Array<(message: string) => void> = [];
205 pendingThreadCreations: Map<
206 string,
207 Promise<{
208 +threadID: string,
209 +threadType: ThreadType,
210 }>,
211 > = new Map<
212 string,
213 Promise<{
214 +threadID: string,
215 +threadType: ThreadType,
216 }>,
217 >();
218
219 // When the user sends a multimedia message that triggers the creation of a
220 // sidebar, the sidebar gets created right away, but the message needs to wait
221 // for the uploads to complete before sending. We use this Set to track the
222 // message localIDs that need sidebarCreation: true.
223 pendingSidebarCreationMessageLocalIDs: Set<string> = new Set<string>();
224
225 static reassignToRealizedThreads<T>(
226 state: { +[threadID: string]: T },
227 props: Props,
228 ): ?{ [threadID: string]: T } {
229 const newState: { [string]: T } = {};
230 let updated = false;
231 for (const threadID in state) {
232 const newThreadID =
233 props.pendingRealizedThreadIDs.get(threadID) ?? threadID;
234 if (newThreadID !== threadID) {
235 updated = true;
236 }
237 newState[newThreadID] = state[threadID];
238 }
239 return updated ? newState : null;
240 }
241
242 static getDerivedStateFromProps(props: Props, state: State): ?Partial<State> {
243 const pendingUploads = InputStateContainer.reassignToRealizedThreads(
244 state.pendingUploads,
245 props,
246 );

Callers

nothing calls this directly

Calls 15

appendFilesMethod · 0.95
sendTextMessageMethod · 0.95
setDraftMethod · 0.95
setTextCursorPositionMethod · 0.95
draftKeyFromThreadIDFunction · 0.90
isBlobServiceURIFunction · 0.90

Tested by

no test coverage detected