From 4a80fe5caf3892712f88dc881adef71bdc40e46b Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Wed, 24 Jun 2020 09:17:59 -0400 Subject: [PATCH] always return a number --- services/gunDB/contact-api/getters/wall.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/gunDB/contact-api/getters/wall.js b/services/gunDB/contact-api/getters/wall.js index da92f1c7..94a919e0 100644 --- a/services/gunDB/contact-api/getters/wall.js +++ b/services/gunDB/contact-api/getters/wall.js @@ -8,15 +8,18 @@ const Key = require('../key') /** * @returns {Promise} */ -const getWallTotalPages = () => - /** @type {Promise} */ (Utils.tryAndWait( +const getWallTotalPages = async () => { + const totalPages = await Utils.tryAndWait( (_, user) => user .get(Key.WALL) .get(Key.NUM_OF_PAGES) .then(), v => typeof v !== 'number' - )) || 0 + ) + + return typeof totalPages === 'number' ? totalPages : 0 +} /** * Won't fail if given an invalid page, will return an empty set.