Reset empty username/password to undefined

Fixes #229
This commit is contained in:
Thomas Nordquist
2019-11-13 09:10:55 +01:00
parent 922f90c4eb
commit 94a92e9b29

View File

@@ -187,10 +187,29 @@ function deleteConnection(state: ConnectionManagerState, action: DeleteConnectio
function updateConnection(state: ConnectionManagerState, action: UpdateConnection): ConnectionManagerState {
let connection = state.connections[action.connectionId]
let changeSet = action.changeSet
// Reset empty username to undefined
if (changeSet.username !== undefined) {
changeSet = {
changeSet,
username: changeSet.username === '' ? undefined : changeSet.username,
}
}
// Reset empty password to undefined
if (changeSet.password !== undefined) {
changeSet = {
changeSet,
username: changeSet.password === '' ? undefined : changeSet.password,
}
}
connection = {
...connection,
...action.changeSet,
...changeSet,
}
return {
...state,
connections: {