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 @@ -78,6 +78,7 @@ import { useSelector } from '../redux/redux-utils'; import { nonThreadCalendarQuery } from '../selectors/nav-selectors'; import { type PendingMultimediaUpload, InputStateContext } from './input-state'; +import type { TypeaheadOverlayState } from './input-state'; type BaseProps = { +children: React.Node, @@ -120,6 +121,8 @@ [threadID: string]: { [localUploadID: string]: PendingMultimediaUpload }, }, +textCursorPositions: { [threadID: string]: number }, + +typeaheadOverlayState: TypeaheadOverlayState, + +chosenPositionInTypeaheadOverlay: number, }; type PropsAndState = { @@ -130,6 +133,8 @@ state: State = { pendingUploads: {}, textCursorPositions: {}, + typeaheadOverlayState: 'hidden', + chosenPositionInTypeaheadOverlay: 0, }; replyCallbacks: Array<(message: string) => void> = []; pendingThreadCreations = new Map>(); @@ -461,10 +466,15 @@ propsAndState.drafts[draftKeyFromThreadID(threadID)], (propsAndState: PropsAndState) => propsAndState.textCursorPositions[threadID], + (propsAndState: PropsAndState) => propsAndState.typeaheadOverlayState, + (propsAndState: PropsAndState) => + propsAndState.chosenPositionInTypeaheadOverlay, ( pendingUploads: ?{ [localUploadID: string]: PendingMultimediaUpload }, draft: ?string, textCursorPosition: ?number, + typeaheadOverlayState: ?TypeaheadOverlayState, + chosenPositionInTypeaheadOverlay: ?number, ) => { let threadPendingUploads = []; const assignedUploads = {}; @@ -486,6 +496,9 @@ assignedUploads, draft: draft ?? '', textCursorPosition: textCursorPosition ?? 0, + typeaheadOverlayState: typeaheadOverlayState ?? 'hidden', + chosenPositionInTypeaheadOverlay: + chosenPositionInTypeaheadOverlay ?? 0, appendFiles: (files: $ReadOnlyArray) => this.appendFiles(threadID, files), cancelPendingUpload: (localUploadID: string) => @@ -499,6 +512,10 @@ setDraft: (newDraft: string) => this.setDraft(threadID, newDraft), setTextCursorPosition: (newPosition: number) => this.setTextCursorPosition(threadID, newPosition), + setTypeaheadOverlayState: (newState: TypeaheadOverlayState) => + this.setTypeaheadOverlayState(newState), + setChosenPositionInTypeaheadOverlay: (newPosition: number) => + this.setChosenPositionInTypeaheadOverlay(newPosition), messageHasUploadFailure: (localMessageID: string) => this.messageHasUploadFailure(assignedUploads[localMessageID]), retryMultimediaMessage: ( @@ -1091,6 +1108,22 @@ }); } + setTypeaheadOverlayState(newState) { + this.setState(() => { + return { + typeaheadOverlayState: newState, + }; + }); + } + + setChosenPositionInTypeaheadOverlay(newPosition) { + this.setState(() => { + return { + chosenPositionInTypeaheadOverlay: newPosition, + }; + }); + } + setProgress( threadID: string, localUploadID: string, diff --git a/web/input/input-state.js b/web/input/input-state.js --- a/web/input/input-state.js +++ b/web/input/input-state.js @@ -34,6 +34,8 @@ selectTime: number, }; +export type TypeaheadOverlayState = 'visible' | 'hidden' | 'accepted'; + // This type represents the input state for a particular thread export type InputState = { +pendingUploads: $ReadOnlyArray, @@ -42,6 +44,8 @@ }, +draft: string, +textCursorPosition: number, + +typeaheadOverlayState: TypeaheadOverlayState, + +chosenPositionInTypeaheadOverlay: number, +appendFiles: (files: $ReadOnlyArray) => Promise, +cancelPendingUpload: (localUploadID: string) => void, +sendTextMessage: ( @@ -51,6 +55,8 @@ +createMultimediaMessage: (localID: number, threadInfo: ThreadInfo) => void, +setDraft: (draft: string) => void, +setTextCursorPosition: (newPosition: number) => void, + +setTypeaheadOverlayState: (newVisibility: TypeaheadOverlayState) => void, + +setChosenPositionInTypeaheadOverlay: (newPosition: number) => void, +messageHasUploadFailure: (localMessageID: string) => boolean, +retryMultimediaMessage: ( localMessageID: string,