| 187 | }; |
| 188 | |
| 189 | class 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 | ); |
nothing calls this directly
no test coverage detected