initialize to 0 and optimize for it

This commit is contained in:
Daniel Lugo 2020-07-11 15:12:24 -04:00
parent 611a5fb093
commit 64c16d88e7
2 changed files with 8 additions and 1 deletions

View file

@ -1513,7 +1513,7 @@ const initWall = async () => {
user
.get(Key.WALL)
.get(Key.NUM_OF_PAGES)
.put(1, ack => {
.put(0, ack => {
if (ack.err) {
rej(new Error(ack.err))
} else {

View file

@ -44,6 +44,13 @@ const getWallPage = async (page, publicKey) => {
)
}
if (totalPages === 0) {
return {
count: 0,
posts: {}
}
}
const actualPageIdx = page < 0 ? totalPages + page : page - 1
if (actualPageIdx > totalPages - 1) {