From 94a92e9b2918f83c1279245761fb1ed76a7d42a9 Mon Sep 17 00:00:00 2001 From: Thomas Nordquist Date: Wed, 13 Nov 2019 09:10:55 +0100 Subject: [PATCH] Reset empty username/password to undefined Fixes #229 --- app/src/reducers/ConnectionManager.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/src/reducers/ConnectionManager.ts b/app/src/reducers/ConnectionManager.ts index 56de274..6ffe4e2 100644 --- a/app/src/reducers/ConnectionManager.ts +++ b/app/src/reducers/ConnectionManager.ts @@ -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: {