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({
mapPropsToValues: ({ defaults }) => ({
name: defaults.name,
host: defaults.host,
port: defaults.port || (defaults.ssl ? '6697' : '6667'),
nick: '',
channels: defaults.channels.join(','),
username: '',
password: defaults.password ? ' ' : '',
realname: '',
ssl: defaults.ssl
}),
mapPropsToValues: ({ defaults }) => {
let port = '6667';
if (defaults.port) {
port = `${defaults.port}`;
} else if (defaults.ssl) {
port = '6697';
}
return {
name: defaults.name,
host: defaults.host,
port,
nick: '',
channels: defaults.channels.join(','),
username: '',
password: defaults.password ? ' ' : '',
realname: '',
ssl: defaults.ssl
};
},
validate: values => {
Object.keys(values).forEach(k => {
if (typeof values[k] === 'string') {