fix: save only new accounts info

This commit is contained in:
José Oliveira 2021-02-12 16:07:52 +00:00 committed by Josh Harvey
parent 54a19b25c1
commit a8fbb57bf6

View file

@ -24,7 +24,9 @@ select $1, $2, $3, $4 where $1 not in (select type from user_config)`
function saveAccounts (accountsToSave) {
return loadAccounts()
.then(currentAccounts => {
const newAccounts = _.assign(currentAccounts, accountsToSave)
const serviceCode = _.keys(accountsToSave)[0]
accountsToSave[serviceCode] = _.omitBy(_.isEmpty, accountsToSave[serviceCode])
const newAccounts = _.merge(currentAccounts, accountsToSave)
return db.none(accountsSql, ['accounts', { accounts: newAccounts }, true, NEW_SETTINGS_LOADER_SCHEMA_VERSION])
})
}