Merge pull request #3208 from lukechampine/save-chat-input

chat-js: store unsent message only on unmount
This commit is contained in:
matildepark 2020-07-28 14:58:02 -04:00 committed by GitHub
commit cdf748531d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -596,7 +596,7 @@ export class ChatScreen extends Component<ChatScreenProps, ChatScreenState> {
envelopes={props.envelopes}
contacts={props.contacts}
onEnter={() => this.setState({ scrollLocked: false })}
onChange={(msg: string) => this.setState({
onUnmount={(msg: string) => this.setState({
messages: this.state.messages.set(props.station, msg)
})}
s3={props.s3}

View File

@ -40,7 +40,7 @@ export class ChatInput extends Component {
super(props);
this.state = {
message: '',
message: props.message,
patpSearch: null
};
@ -99,6 +99,10 @@ export class ChatInput extends Component {
});
}
componentWillUnmount() {
this.props.onUnmount(this.state.message);
}
nextAutocompleteSuggestion(backward = false) {
const { patpSuggestions } = this.state;
let idx = patpSuggestions.findIndex(s => s === this.state.selectedSuggestion);
@ -150,7 +154,9 @@ export class ChatInput extends Component {
if(patpSearch !== null) {
this.patpAutocomplete(value, false);
}
this.props.onChange(value);
this.setState({
message: value
});
}
getLetterType(letter) {