From 652e7b75cdb162af9635103f70fa76515170ec29 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Mon, 10 Aug 2020 23:51:37 -0400 Subject: [PATCH 1/2] chat: autofocus on desktop, not mobile --- pkg/interface/src/apps/chat/components/lib/chat-editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/interface/src/apps/chat/components/lib/chat-editor.js b/pkg/interface/src/apps/chat/components/lib/chat-editor.js index 99a07f4cf..ff5ee402e 100644 --- a/pkg/interface/src/apps/chat/components/lib/chat-editor.js +++ b/pkg/interface/src/apps/chat/components/lib/chat-editor.js @@ -124,7 +124,7 @@ export default class ChatEditor extends Component { onChange={(e, d, v) => this.messageChange(e, d, v)} editorDidMount={(editor) => { this.editor = editor; - if (BROWSER_REGEX.test(navigator.userAgent)) { + if (!(BROWSER_REGEX.test(navigator.userAgent))) { editor.focus(); } }} From b0e83ad5941fda20b66fab7a9bed5c11fdf0468c Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Mon, 10 Aug 2020 23:53:17 -0400 Subject: [PATCH 2/2] chat: prevent retaining sent message on unmount Fixes #3272. --- pkg/interface/src/apps/chat/components/chat.tsx | 5 ++++- pkg/interface/src/apps/chat/components/lib/chat-editor.js | 6 ++++++ pkg/interface/src/apps/chat/components/lib/chat-input.js | 4 +++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/interface/src/apps/chat/components/chat.tsx b/pkg/interface/src/apps/chat/components/chat.tsx index fd5b4edb2..6a06135ff 100644 --- a/pkg/interface/src/apps/chat/components/chat.tsx +++ b/pkg/interface/src/apps/chat/components/chat.tsx @@ -94,7 +94,7 @@ export class ChatScreen extends Component { props.chatSynced && !(props.station in props.chatSynced) && props.envelopes.length > 0; - + const unreadCount = props.length - props.read; const unreadMsg = unreadCount > 0 && props.envelopes[unreadCount - 1]; @@ -141,6 +141,9 @@ export class ChatScreen extends Component { s3={props.s3} placeholder="Message..." message={this.state.messages.get(props.station) || ""} + deleteMessage={() => this.setState({ + messages: this.state.messages.set(props.station, "") + })} /> ); diff --git a/pkg/interface/src/apps/chat/components/lib/chat-editor.js b/pkg/interface/src/apps/chat/components/lib/chat-editor.js index ff5ee402e..a62d47367 100644 --- a/pkg/interface/src/apps/chat/components/lib/chat-editor.js +++ b/pkg/interface/src/apps/chat/components/lib/chat-editor.js @@ -80,11 +80,17 @@ export default class ChatEditor extends Component { return; } + this.setState({ message: '' }); this.props.submit(editorMessage); this.editor.setValue(''); } messageChange(editor, data, value) { + if (this.state.message !== '' && value == '') { + this.setState({ + message: value + }); + } if (value == this.props.message || value == '' || value == ' ') { return; } diff --git a/pkg/interface/src/apps/chat/components/lib/chat-input.js b/pkg/interface/src/apps/chat/components/lib/chat-input.js index f4a6c2916..eedc066e9 100644 --- a/pkg/interface/src/apps/chat/components/lib/chat-input.js +++ b/pkg/interface/src/apps/chat/components/lib/chat-input.js @@ -10,7 +10,7 @@ const URL_REGEX = new RegExp(String(/^((\w+:\/\/)[-a-zA-Z0-9:@;?&=\/%\+\.\*!'\(\ export class ChatInput extends Component { constructor(props) { super(props); - + this.state = { inCodeMode: false, }; @@ -141,6 +141,8 @@ export class ChatInput extends Component { messages.push(message); } + props.deleteMessage(); + messages.forEach((message) => { if (message.length > 0) { message = this.getLetterType(message.join(' '));