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 }) => {
let port = '6667';
if (defaults.port) {
port = `${defaults.port}`;
} else if (defaults.ssl) {
port = '6697';
}
return {
name: defaults.name, name: defaults.name,
host: defaults.host, host: defaults.host,
port: defaults.port || (defaults.ssl ? '6697' : '6667'), port,
nick: '', nick: '',
channels: defaults.channels.join(','), channels: defaults.channels.join(','),
username: '', username: '',
password: defaults.password ? ' ' : '', password: defaults.password ? ' ' : '',
realname: '', realname: '',
ssl: defaults.ssl 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') {