Changeset View
Changeset View
Standalone View
Standalone View
web/chat/chat-input-bar.react.js
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | if (this.props.isThreadActive && !prevProps.isThreadActive) { | ||||
this.removeReplyListener(); | this.removeReplyListener(); | ||||
} | } | ||||
const { inputState } = this.props; | const { inputState } = this.props; | ||||
const prevInputState = prevProps.inputState; | const prevInputState = prevProps.inputState; | ||||
if (inputState.draft !== prevInputState.draft) { | if (inputState.draft !== prevInputState.draft) { | ||||
this.updateHeight(); | this.updateHeight(); | ||||
} | } | ||||
if ( | |||||
inputState.draft !== prevInputState.draft || | |||||
inputState.textCursorPosition !== prevInputState.textCursorPosition | |||||
) { | |||||
inputState.setTypeaheadState({ | |||||
canBeVisible: true, | |||||
}); | |||||
} | |||||
const curUploadIDs = ChatInputBar.unassignedUploadIDs( | const curUploadIDs = ChatInputBar.unassignedUploadIDs( | ||||
inputState.pendingUploads, | inputState.pendingUploads, | ||||
); | ); | ||||
const prevUploadIDs = ChatInputBar.unassignedUploadIDs( | const prevUploadIDs = ChatInputBar.unassignedUploadIDs( | ||||
prevInputState.pendingUploads, | prevInputState.pendingUploads, | ||||
); | ); | ||||
if ( | if ( | ||||
this.multimediaInput && | this.multimediaInput && | ||||
▲ Show 20 Lines • Show All 205 Lines • ▼ Show 20 Lines | ) { | ||||
<span className={css.explanation}> | <span className={css.explanation}> | ||||
You don't have permission to send messages. | You don't have permission to send messages. | ||||
</span> | </span> | ||||
); | ); | ||||
} | } | ||||
let typeaheadTooltip; | let typeaheadTooltip; | ||||
if ( | if ( | ||||
this.props.inputState.typeaheadState.canBeVisible && | |||||
this.props.suggestedUsers.length > 0 && | this.props.suggestedUsers.length > 0 && | ||||
this.props.typeaheadMatchedStrings && | this.props.typeaheadMatchedStrings && | ||||
this.textarea | this.textarea | ||||
) { | ) { | ||||
typeaheadTooltip = ( | typeaheadTooltip = ( | ||||
<TypeaheadTooltip | <TypeaheadTooltip | ||||
inputState={this.props.inputState} | inputState={this.props.inputState} | ||||
textarea={this.textarea} | textarea={this.textarea} | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | focusAndUpdateText = (text: string) => { | ||||
} | } | ||||
// The above strategies make sure the cursor is at the end, | // The above strategies make sure the cursor is at the end, | ||||
// but we also need to make sure that we're scrolled to the bottom | // but we also need to make sure that we're scrolled to the bottom | ||||
textarea.scrollTop = textarea.scrollHeight; | textarea.scrollTop = textarea.scrollHeight; | ||||
}; | }; | ||||
onKeyDown = (event: SyntheticKeyboardEvent<HTMLTextAreaElement>) => { | onKeyDown = (event: SyntheticKeyboardEvent<HTMLTextAreaElement>) => { | ||||
if (event.key === 'Enter' && !event.shiftKey) { | const { | ||||
accept, | |||||
close, | |||||
moveChoiceUp, | |||||
moveChoiceDown, | |||||
} = this.props.inputState.typeaheadState; | |||||
const actions = { | |||||
Enter: accept, | |||||
Tab: accept, | |||||
ArrowDown: moveChoiceDown, | |||||
ArrowUp: moveChoiceUp, | |||||
Escape: close, | |||||
}; | |||||
if ( | |||||
this.props.inputState.typeaheadState.canBeVisible && | |||||
actions[event.key] | |||||
) { | |||||
event.preventDefault(); | |||||
actions[event.key](); | |||||
} else if (event.key === 'Enter' && !event.shiftKey) { | |||||
event.preventDefault(); | event.preventDefault(); | ||||
this.send(); | this.send(); | ||||
} | } | ||||
}; | }; | ||||
onSend = (event: SyntheticEvent<HTMLAnchorElement>) => { | onSend = (event: SyntheticEvent<HTMLAnchorElement>) => { | ||||
event.preventDefault(); | event.preventDefault(); | ||||
this.send(); | this.send(); | ||||
▲ Show 20 Lines • Show All 174 Lines • Show Last 20 Lines |