Changeset View
Changeset View
Standalone View
Standalone View
native/chat/chat-input-bar.react.js
Show First 20 Lines • Show All 622 Lines • ▼ Show 20 Lines | this.props.dispatch({ | ||||
type: updateDraftActionType, | type: updateDraftActionType, | ||||
payload: { | payload: { | ||||
key: draftKeyFromThreadID(this.props.threadInfo.id), | key: draftKeyFromThreadID(this.props.threadInfo.id), | ||||
text, | text, | ||||
}, | }, | ||||
}); | }); | ||||
}, 400); | }, 400); | ||||
focusAndUpdateTextAndSelection = (text: string, selection: Selection) => { | |||||
this.setState({ | |||||
text, | |||||
textEdited: true, | |||||
selection, | |||||
}); | |||||
this.saveDraft(text); | |||||
this.focusAndUpdateButtonsVisibility(); | |||||
}; | |||||
focusAndUpdateText = (text: string) => { | focusAndUpdateText = (text: string) => { | ||||
const currentText = this.state.text; | |||||
if (!currentText.startsWith(text)) { | |||||
const prependedText = text.concat(currentText); | |||||
this.updateText(prependedText); | |||||
} | |||||
this.focusAndUpdateButtonsVisibility(); | |||||
}; | |||||
focusAndUpdateButtonsVisibility = () => { | |||||
const { textInput } = this; | const { textInput } = this; | ||||
if (!textInput) { | if (!textInput) { | ||||
return; | return; | ||||
} | } | ||||
const currentText = this.state.text; | |||||
if (!currentText.startsWith(text)) { | |||||
const prependedText = text.concat(currentText); | |||||
this.updateText(prependedText); | |||||
this.immediatelyShowSendButton(); | this.immediatelyShowSendButton(); | ||||
this.immediatelyHideButtons(); | this.immediatelyHideButtons(); | ||||
} | |||||
textInput.focus(); | textInput.focus(); | ||||
}; | }; | ||||
onSend = async () => { | onSend = async () => { | ||||
if (!trimMessage(this.state.text)) { | if (!trimMessage(this.state.text)) { | ||||
return; | return; | ||||
} | } | ||||
this.updateSendButton(''); | this.updateSendButton(''); | ||||
▲ Show 20 Lines • Show All 374 Lines • Show Last 20 Lines |