From 64c16d88e7e83e88aeff0b1d3bdea095a19fcb87 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Sat, 11 Jul 2020 15:12:24 -0400 Subject: [PATCH] initialize to 0 and optimize for it --- services/gunDB/contact-api/actions.js | 2 +- services/gunDB/contact-api/getters/wall.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/services/gunDB/contact-api/actions.js b/services/gunDB/contact-api/actions.js index 2f490d5a..25b98004 100644 --- a/services/gunDB/contact-api/actions.js +++ b/services/gunDB/contact-api/actions.js @@ -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 { diff --git a/services/gunDB/contact-api/getters/wall.js b/services/gunDB/contact-api/getters/wall.js index 73eb210f..83cdb5a7 100644 --- a/services/gunDB/contact-api/getters/wall.js +++ b/services/gunDB/contact-api/getters/wall.js @@ -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) {