Skip to content

Commit

Permalink
Add sendButtonPressed function
Browse files Browse the repository at this point in the history
  • Loading branch information
emaciel10 committed Jan 29, 2019
1 parent a92e5b6 commit 895ae85
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions client/src/components/PlaceOverlay/PlaceOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class PlaceOverlay extends React.PureComponent {
};

this.savePlaceName = this.savePlaceName.bind(this);
this.sendButtonPressed = this.sendButtonPressed.bind(this);
}

componentWillReceiveProps(nextProps) {
Expand All @@ -40,6 +41,18 @@ class PlaceOverlay extends React.PureComponent {
}
}

sendButtonPressed() {
const { place } = this.props;

if (!this.state.messageText) return;

Realtime.createMessage({
text: this.state.messageText,
placeId: place._id,
});
this.setState({ messageText: "" });
}

render() {
const { place } = this.props;
return (
Expand Down Expand Up @@ -77,18 +90,7 @@ class PlaceOverlay extends React.PureComponent {
/>
</View>
<View style={styles.sendWrapper}>
<Button
title="Send"
onPress={() => {
if (!this.state.messageText) return;

Realtime.createMessage({
text: this.state.messageText,
placeId: place._id,
});
this.setState({ messageText: "" });
}}
/>
<Button title="Send" onPress={this.sendButtonPressed} />
</View>
</View>
<View style={styles.closeWrapper}>
Expand Down

0 comments on commit 895ae85

Please sign in to comment.