diff --git a/web/input/input-state-container.react.js b/web/input/input-state-container.react.js --- a/web/input/input-state-container.react.js +++ b/web/input/input-state-container.react.js @@ -84,6 +84,7 @@ type Props = { ...BaseProps, +activeChatThreadID: ?string, + +drafts: { +[key: string]: string }, +viewerID: ?string, +messageStoreMessages: { +[id: string]: RawMessageInfo }, +exifRotate: boolean, @@ -117,12 +118,12 @@ +pendingUploads: { [threadID: string]: { [localUploadID: string]: PendingMultimediaUpload }, }, - +drafts: { [threadID: string]: string }, + +drafts: { +[key: string]: string }, }; class InputStateContainer extends React.PureComponent { state: State = { pendingUploads: {}, - drafts: {}, + drafts: this.props.drafts, }; replyCallbacks: Array<(message: string) => void> = []; pendingThreadCreations = new Map>(); @@ -1055,8 +1056,15 @@ } setDraft(threadID: string, draft: string) { + const newThreadID = this.getRealizedOrPendingThreadID(threadID); + this.props.dispatch({ + type: 'UPDATE_DRAFT', + payload: { + key: newThreadID, + text: draft, + }, + }); this.setState(prevState => { - const newThreadID = this.getRealizedOrPendingThreadID(threadID); return { drafts: { ...prevState.drafts, @@ -1212,7 +1220,7 @@ render() { const { activeChatThreadID } = this.props; const inputState = activeChatThreadID - ? this.inputStateSelector(activeChatThreadID)(this.state) + ? this.inputStateSelector(activeChatThreadID)(this.state, this.props) : null; return ( @@ -1233,6 +1241,7 @@ const activeChatThreadID = useSelector( state => state.navInfo.activeChatThreadID, ); + const drafts = useSelector(state => state.draftStore.drafts); const viewerID = useSelector( state => state.currentUserInfo && state.currentUserInfo.id, ); @@ -1273,6 +1282,7 @@