chat: prevent retaining sent message on unmount

Fixes #3272.
This commit is contained in:
Matilde Park 2020-08-10 23:53:17 -04:00
parent 652e7b75cd
commit b0e83ad594
3 changed files with 13 additions and 2 deletions

View File

@ -141,6 +141,9 @@ export class ChatScreen extends Component<ChatScreenProps, ChatScreenState> {
s3={props.s3}
placeholder="Message..."
message={this.state.messages.get(props.station) || ""}
deleteMessage={() => this.setState({
messages: this.state.messages.set(props.station, "")
})}
/>
</div>
);

View File

@ -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;
}

View File

@ -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(' '));