Skip to content

Commit

Permalink
Prevent submitting an invalid Pine server with keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyej committed Jan 3, 2020
1 parent 3e016f0 commit 38b4a15
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/screens/settings/ChangePineServerScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class ChangePineServerScreen extends Component {
super(...arguments);

this.state = {
hostname: props.settings.pineAddressHostname
hostname: props.settings.pineAddressHostname,
canSubmit: false
};

this._onStatusUpdated = this._onStatusUpdated.bind(this);
Expand All @@ -65,7 +66,11 @@ class ChangePineServerScreen extends Component {

_onSubmit() {
const { dispatch, screenProps } = this.props;
const { hostname } = this.state;
const { hostname, canSubmit } = this.state;

if (!canSubmit) {
return;
}

dispatch(saveSettings({
pineAddressHostname: hostname
Expand All @@ -79,8 +84,10 @@ class ChangePineServerScreen extends Component {
}

_onChangeHostname(hostname) {
this.setState({ hostname });
this.props.navigation.setParams({ canSubmit: false });
const canSubmit = false;

this.setState({ hostname, canSubmit });
this.props.navigation.setParams({ canSubmit });
}

_onStatusUpdated(ok) {
Expand All @@ -89,6 +96,7 @@ class ChangePineServerScreen extends Component {
const newHostname = this.state.hostname;
const canSubmit = ok && newHostname !== oldHostname;

this.setState({ canSubmit });
navigation.setParams({ canSubmit });
}

Expand Down

0 comments on commit 38b4a15

Please sign in to comment.