init writes in parallel in case one of them fails

This commit is contained in:
Daniel Lugo 2020-07-29 12:21:46 -04:00
parent 755bafba8a
commit 7974a89bd3

View file

@ -1543,7 +1543,10 @@ const unfollow = publicKey =>
const initWall = async () => {
const user = require('../Mediator').getUser()
await new Promise((res, rej) => {
const promises = []
promises.push(
new Promise((res, rej) => {
user
.get(Key.WALL)
.get(Key.NUM_OF_PAGES)
@ -1555,8 +1558,10 @@ const initWall = async () => {
}
})
})
)
await new Promise((res, rej) => {
promises.push(
new Promise((res, rej) => {
user
.get(Key.WALL)
.get(Key.PAGES)
@ -1575,8 +1580,10 @@ const initWall = async () => {
}
)
})
)
await new Promise((res, rej) => {
promises.push(
new Promise((res, rej) => {
user
.get(Key.WALL)
.get(Key.PAGES)
@ -1590,6 +1597,9 @@ const initWall = async () => {
}
})
})
)
await Promise.all(promises)
}
module.exports = {