init writes in parallel in case one of them fails
This commit is contained in:
parent
755bafba8a
commit
7974a89bd3
1 changed files with 50 additions and 40 deletions
|
|
@ -1543,53 +1543,63 @@ const unfollow = publicKey =>
|
||||||
const initWall = async () => {
|
const initWall = async () => {
|
||||||
const user = require('../Mediator').getUser()
|
const user = require('../Mediator').getUser()
|
||||||
|
|
||||||
await new Promise((res, rej) => {
|
const promises = []
|
||||||
user
|
|
||||||
.get(Key.WALL)
|
|
||||||
.get(Key.NUM_OF_PAGES)
|
|
||||||
.put(0, ack => {
|
|
||||||
if (ack.err) {
|
|
||||||
rej(new Error(ack.err))
|
|
||||||
} else {
|
|
||||||
res()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
await new Promise((res, rej) => {
|
promises.push(
|
||||||
user
|
new Promise((res, rej) => {
|
||||||
.get(Key.WALL)
|
user
|
||||||
.get(Key.PAGES)
|
.get(Key.WALL)
|
||||||
.get('0')
|
.get(Key.NUM_OF_PAGES)
|
||||||
.get(Key.POSTS)
|
.put(0, ack => {
|
||||||
.put(
|
|
||||||
{
|
|
||||||
unused: null
|
|
||||||
},
|
|
||||||
ack => {
|
|
||||||
if (ack.err) {
|
if (ack.err) {
|
||||||
rej(new Error(ack.err))
|
rej(new Error(ack.err))
|
||||||
} else {
|
} else {
|
||||||
res()
|
res()
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
)
|
})
|
||||||
})
|
)
|
||||||
|
|
||||||
await new Promise((res, rej) => {
|
promises.push(
|
||||||
user
|
new Promise((res, rej) => {
|
||||||
.get(Key.WALL)
|
user
|
||||||
.get(Key.PAGES)
|
.get(Key.WALL)
|
||||||
.get('0')
|
.get(Key.PAGES)
|
||||||
.get(Key.COUNT)
|
.get('0')
|
||||||
.put(0, ack => {
|
.get(Key.POSTS)
|
||||||
if (ack.err) {
|
.put(
|
||||||
rej(new Error(ack.err))
|
{
|
||||||
} else {
|
unused: null
|
||||||
res()
|
},
|
||||||
}
|
ack => {
|
||||||
})
|
if (ack.err) {
|
||||||
})
|
rej(new Error(ack.err))
|
||||||
|
} else {
|
||||||
|
res()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
promises.push(
|
||||||
|
new Promise((res, rej) => {
|
||||||
|
user
|
||||||
|
.get(Key.WALL)
|
||||||
|
.get(Key.PAGES)
|
||||||
|
.get('0')
|
||||||
|
.get(Key.COUNT)
|
||||||
|
.put(0, ack => {
|
||||||
|
if (ack.err) {
|
||||||
|
rej(new Error(ack.err))
|
||||||
|
} else {
|
||||||
|
res()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
await Promise.all(promises)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue