Make sure the connect form port is always a string

This commit is contained in:
Ken-Håvard Lieng 2018-05-18 05:13:25 +02:00
parent 4ac0dd7c4b
commit d27d108a07
2 changed files with 23 additions and 14 deletions

File diff suppressed because one or more lines are too long

View File

@ -102,17 +102,26 @@ class Connect extends Component {
} }
export default withFormik({ export default withFormik({
mapPropsToValues: ({ defaults }) => ({ mapPropsToValues: ({ defaults }) => {
name: defaults.name, let port = '6667';
host: defaults.host, if (defaults.port) {
port: defaults.port || (defaults.ssl ? '6697' : '6667'), port = `${defaults.port}`;
nick: '', } else if (defaults.ssl) {
channels: defaults.channels.join(','), port = '6697';
username: '', }
password: defaults.password ? ' ' : '',
realname: '', return {
ssl: defaults.ssl name: defaults.name,
}), host: defaults.host,
port,
nick: '',
channels: defaults.channels.join(','),
username: '',
password: defaults.password ? ' ' : '',
realname: '',
ssl: defaults.ssl
};
},
validate: values => { validate: values => {
Object.keys(values).forEach(k => { Object.keys(values).forEach(k => {
if (typeof values[k] === 'string') { if (typeof values[k] === 'string') {