initialize wall subgraph at sign up

This commit is contained in:
Daniel Lugo 2020-07-11 12:57:16 -04:00
parent b44827f00d
commit 16dd004000
2 changed files with 59 additions and 1 deletions

View file

@ -1303,6 +1303,7 @@ const register = async (alias, pass) => {
await API.Actions.setDisplayName('anon' + pub.slice(0, 8), user)
await API.Actions.generateHandshakeAddress()
await API.Actions.generateOrderAddress(user)
await API.Actions.initWall()
await API.Actions.setBio('A little bit about myself.', user)
return pub
})

View file

@ -1502,6 +1502,62 @@ const unfollow = publicKey =>
})
})
/**
* @throws {Error}
* @returns {Promise<void>}
*/
const initWall = async () => {
const user = require('../Mediator').getUser()
await new Promise((res, rej) => {
user
.get(Key.WALL)
.get(Key.NUM_OF_PAGES)
.put(1, ack => {
if (ack.err) {
rej(new Error(ack.err))
} else {
res()
}
})
})
await new Promise((res, rej) => {
user
.get(Key.WALL)
.get(Key.PAGES)
.get('0')
.get(Key.POSTS)
.put(
{
unused: null
},
ack => {
if (ack.err) {
rej(new Error(ack.err))
} else {
res()
}
}
)
})
await 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()
}
})
})
}
module.exports = {
__createOutgoingFeed,
acceptRequest,
@ -1524,5 +1580,6 @@ module.exports = {
createPost,
deletePost,
follow,
unfollow
unfollow,
initWall
}