Close/cancel draft "reply to" on Escape (#4387)

This commit is contained in:
Jan Janik 2020-07-01 03:59:38 +02:00 committed by GitHub
parent c907fd36ba
commit 1503053496
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View file

@ -458,6 +458,8 @@
this.onEditorStateChange(msg, caretLocation), this.onEditorStateChange(msg, caretLocation),
onTextTooLong: () => this.showToast(Whisper.MessageBodyTooLongToast), onTextTooLong: () => this.showToast(Whisper.MessageBodyTooLongToast),
onChooseAttachment: this.onChooseAttachment.bind(this), onChooseAttachment: this.onChooseAttachment.bind(this),
getQuotedMessage: () => this.model.get('quotedMessageId'),
clearQuotedMessage: () => this.setQuoteMessage(null),
micCellEl, micCellEl,
attachmentListEl, attachmentListEl,
}; };
@ -2582,8 +2584,7 @@
this.quotedMessage = message; this.quotedMessage = message;
if (message) { if (message) {
const quote = await this.model.makeQuote(this.quotedMessage); this.quote = await this.model.makeQuote(this.quotedMessage);
this.quote = quote;
this.focusMessageFieldAndClearDisabled(); this.focusMessageFieldAndClearDisabled();
} }

View file

@ -43,7 +43,7 @@ export type Props = Pick<
| 'onEditorSizeChange' | 'onEditorSizeChange'
| 'onEditorStateChange' | 'onEditorStateChange'
| 'onTextTooLong' | 'onTextTooLong'
| 'startingText' | 'startingText' | 'clearQuotedMessage' | 'getQuotedMessage'
> & > &
Pick< Pick<
EmojiButtonProps, EmojiButtonProps,
@ -102,6 +102,8 @@ export const CompositionArea = ({
clearShowIntroduction, clearShowIntroduction,
showPickerHint, showPickerHint,
clearShowPickerHint, clearShowPickerHint,
clearQuotedMessage,
getQuotedMessage,
}: Props) => { }: Props) => {
const [disabled, setDisabled] = React.useState(false); const [disabled, setDisabled] = React.useState(false);
const [showMic, setShowMic] = React.useState(!startingText); const [showMic, setShowMic] = React.useState(!startingText);
@ -339,6 +341,8 @@ export const CompositionArea = ({
onDirtyChange={setDirty} onDirtyChange={setDirty}
skinTone={skinTone} skinTone={skinTone}
startingText={startingText} startingText={startingText}
clearQuotedMessage={clearQuotedMessage}
getQuotedMessage={getQuotedMessage}
/> />
</div> </div>
{!large ? ( {!large ? (

View file

@ -42,6 +42,8 @@ export type Props = {
onTextTooLong(): unknown; onTextTooLong(): unknown;
onPickEmoji(o: EmojiPickDataType): unknown; onPickEmoji(o: EmojiPickDataType): unknown;
onSubmit(message: string): unknown; onSubmit(message: string): unknown;
getQuotedMessage(): unknown;
clearQuotedMessage(): unknown;
}; };
export type InputApi = { export type InputApi = {
@ -217,6 +219,8 @@ export const CompositionInput = ({
onSubmit, onSubmit,
skinTone, skinTone,
startingText, startingText,
getQuotedMessage,
clearQuotedMessage,
}: Props) => { }: Props) => {
const [editorRenderState, setEditorRenderState] = React.useState( const [editorRenderState, setEditorRenderState] = React.useState(
getInitialEditorState(startingText) getInitialEditorState(startingText)
@ -462,6 +466,8 @@ export const CompositionInput = ({
if (emojiResults.length > 0) { if (emojiResults.length > 0) {
e.preventDefault(); e.preventDefault();
resetEmojiResults(); resetEmojiResults();
} else if (getQuotedMessage()) {
clearQuotedMessage();
} }
}, },
[resetEmojiResults, emojiResults] [resetEmojiResults, emojiResults]