refactor: use a single DB task to load the latest settings
This commit is contained in:
parent
593f7fe949
commit
dddbe98fca
1 changed files with 14 additions and 11 deletions
|
|
@ -168,16 +168,19 @@ function migrationSaveConfig(config) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadLatest(schemaVersion) {
|
const loadLatest = schemaVersion =>
|
||||||
return Promise.all([
|
db
|
||||||
loadLatestConfigOrNoneReturningVersion(schemaVersion),
|
.task(t =>
|
||||||
loadAccounts(schemaVersion),
|
t.batch([
|
||||||
]).then(([configObj, accounts]) => ({
|
loadLatestConfigOrNoneReturningVersion(t, schemaVersion),
|
||||||
config: configObj.config,
|
_loadAccounts(t, schemaVersion),
|
||||||
accounts,
|
]),
|
||||||
version: configObj.version,
|
)
|
||||||
}))
|
.then(([configObj, accounts]) => ({
|
||||||
}
|
config: configObj.config,
|
||||||
|
accounts,
|
||||||
|
version: configObj.version,
|
||||||
|
}))
|
||||||
|
|
||||||
function loadLatestConfig() {
|
function loadLatestConfig() {
|
||||||
const sql = `SELECT data
|
const sql = `SELECT data
|
||||||
|
|
@ -196,7 +199,7 @@ function loadLatestConfig() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadLatestConfigOrNoneReturningVersion(schemaVersion) {
|
function loadLatestConfigOrNoneReturningVersion(db, schemaVersion) {
|
||||||
const sql = `SELECT data, id
|
const sql = `SELECT data, id
|
||||||
FROM user_config
|
FROM user_config
|
||||||
WHERE type = 'config'
|
WHERE type = 'config'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue