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