Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Fix bug in member user database load code
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrazee committed Feb 8, 2021
1 parent 4be5946 commit 5763818
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions db/index.js
Expand Up @@ -149,9 +149,10 @@ async function saveDbConfig () {
}

async function loadMemberUserDbs () {
let numLoaded = 0
let users = await publicServerDb.users.list()
for (let user of users) {
if (user.type === 'citizen') {
if (user.value.type === 'citizen') {
let publicUserDb = new PublicCitizenDB(user.value.userId, hyperUrlToKey(user.value.dbUrl))
await publicUserDb.setup()
publicUserDbs.set(constructUserId(user.key), publicUserDb)
Expand All @@ -165,16 +166,22 @@ async function loadMemberUserDbs () {
privateUserDbs.set(constructUserId(user.key), privateUserDb)
privateUserDb.on('subscriptions-changed', loadOrUnloadExternalUserDbs)
await catchupIndexes(privateUserDb)
} else if (user.type === 'community') {

numLoaded++
} else if (user.value.type === 'community') {
let publicUserDb = new PublicCommunityDB(user.value.userId, hyperUrlToKey(user.value.dbUrl))
await publicUserDb.setup()
publicUserDbs.set(constructUserId(user.key), publicUserDb)
publicUserDb.watch(onDatabaseChange)
publicUserDb.on('subscriptions-changed', loadOrUnloadExternalUserDbs)
await catchupIndexes(publicUserDb)
numLoaded++
} else {
console.error('Unknown user type record:', user.type)
console.error(user)
}
}
console.log('Loaded', users.length, 'member user databases')
console.log('Loaded', numLoaded, 'user DBs (from', users.length, 'member records)')
}

export function* getAllDbs () {
Expand Down

0 comments on commit 5763818

Please sign in to comment.