Merge remote-tracking branch 'upstream/release-8.0' into merge-release-8.0-into-dev-220906

This commit is contained in:
Taranto 2022-06-09 23:56:40 +01:00
commit 4023470fec
47 changed files with 410 additions and 149 deletions

View file

@ -54,10 +54,13 @@ const accountsSql = `update user_config set data = $2, valid = $3, schema_versio
insert into user_config (type, data, valid, schema_version)
select $1, $2, $3, $4 where $1 not in (select type from user_config)`
function saveAccounts (accounts) {
return loadAccounts()
.then(currentAccounts => {
return Promise.all([loadAccounts(), getOperatorId('middleware')])
.then(([currentAccounts, operatorId]) => {
const newAccounts = _.merge(currentAccounts, accounts)
return db.none(accountsSql, ['accounts', { accounts: newAccounts }, true, NEW_SETTINGS_LOADER_SCHEMA_VERSION])
return db.tx(t => {
return t.none(accountsSql, ['accounts', { accounts: newAccounts }, true, NEW_SETTINGS_LOADER_SCHEMA_VERSION])
.then(() => t.none('NOTIFY $1:name, $2', ['reload', JSON.stringify({ schema: asyncLocalStorage.getStore().get('schema'), operatorId })]))
}).catch(console.error)
})
}
function resetAccounts (schemaVersion) {